NixOS / nixops

NixOps is a tool for deploying to NixOS machines in a network or cloud.
https://nixos.org/nixops
GNU Lesser General Public License v3.0
1.85k stars 365 forks source link

libvirt port forwarding #1193

Open gjabell opened 5 years ago

gjabell commented 5 years ago

Hey all,

I'm looking for a reasonable way to forward ports from a host machine to a NixOps VM using the libvirt backend. It seems the de-facto way to forward ports with libvirt is using iptables, but that requires changes to the host's configuration.nix and doesn't allow NixOps to manage the port forwards. There is a somewhat hacky way to do this with virtualbox (see #734). One solution might be to use a qemu:commandline block as in:

    <qemu:commandline>
        <!-- forward ssh -->
        <qemu:arg value='-netdev' />
        <qemu:arg value='user,id=eth0,hostfwd=tcp::{{ host_port }}-:{{ vm_port }}'/>
        <qemu:arg value='-device'/>
        <qemu:arg value='virtio-net,netdev=eth0'/>
    </qemu:commandline>

but that requires adding the qemu namespace to the generate XML file, which isn't currently supported.

Does anyone have an existing solution for this?

Thanks!

Reilithion commented 5 years ago

I would also benefit from a way to accomplish this. (unfortunately I'm also not sure how to implement a solution)