I am trying to port forward for an Ubuntu Focal VM (sourced from ubuntu:
) on the current/latest version of LXD. It requires a static IP (simple to do for containers). But for VMs, two things differ:
-
I set it using
lxc config device override <instance> <nic> ipv4.address=a.b.c.d
. But the fact that inlxc list
NIC is calledeth0
when the VM starts then changes toenp5s0
, it seems to have worked usingeth0
. Is it proper to setup usingeth0
? Or should I wait for it to finish booting and useenp5s0
? -
I will leave this here as a reference (not a question), since it is explained in Virtual machine proxy devices - #2 by tomp and Instance configuration - LXD documentation that the only way port fwd VMs is with
nat=true
(after assigning a static IP to the VM). The actual cmd sequence is (note thenat=true
part, it is mentioned but the cmd not shown). For the sake of completeness I am listing the entire sequence here:
lxc profile create $instance-$name-$port-$tcpudp
lxc profile add $instance $instance-$name-$port-$tcpudp
lxc profile device add $instance-$name-$port-$tcpudp hostport-$ct-$name-$port-$tcpudp proxy connect="$tcpudp:$ip:$port" listen="$tcpudp:<HostStaticIP>:$port" **nat="true"**
... you might want to add cmds to open up the host's firewall also in this routine.
where $name is the name of the rule/profile, $ip is the static IP of the container, $port is the port and $tcpudp is one or the other.