How to configure a port forwarding or a port redirect in LXD/LXC Virtual Machine
If you are looking how to do the same for LXC containers, look here.
Unlike port forwarding for containers, virtual machines require you to set a static IP address before you can configure the proxy device.
If you don’t have a static IP address configured for you virtual machine, use this example command:
lxc config device override <vm-name> eth0 ipv4.address=192.168.1.123
Once you have this done now go ahead and create a proxy device. It will look different from the command used for containers:
lxc config device add <vm-name> <device-name> \ proxy listen=tcp:<ip-of-host-interface>:22 connect=tcp:192.168.1.123:22 nat=true
Insert your own virtual machine name. Device name can be something like “ssh-port-forward” or something. Make sure you know the IP address of the host server.