Correct, as it is network (DNAT) based rather than using a proxy process to translate connection types.
To create a port based network forward, lets image we have an IP on the LXD host of 192.168.1.200 and an instance connected to the lxdbr0 network with a static IP of 10.147.102.2/24.
lxc network show lxdbr0
config:
ipv4.address: 10.147.102.1/24
ipv4.nat: "true"
ipv6.nat: "true"
description: ""
name: lxdbr0
type: bridge
lxc init images:ubuntu/focal c1
lxc config device override c1 eth0 ipv4.address=10.147.102.2
lxc start c1
lxc ls
+------+---------+---------------------+----------------------------------------------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+---------+---------------------+----------------------------------------------+-----------+-----------+
| c1 | RUNNING | 10.147.102.2 (eth0) | fd42:ab1f:7a24:8e73:216:3eff:fe70:a44 (eth0) | CONTAINER | 0 |
+------+---------+---------------------+----------------------------------------------+-----------+-----------+
Now setup the forward listening on 192.168.1.200 forwarding to 10.147.102.2:
lxc network forward create lxdbr0 192.168.1.200
lxc network forward port add lxdbr0 192.168.1.200 udp 53 10.147.102.2 53
lxc network forward port add lxdbr0 192.168.1.200 tcp 53 10.147.102.2 53
lxc network forward show lxdbr0 192.168.1.200
description: ""
config: {}
ports:
- description: ""
protocol: udp
listen_port: "53"
target_port: "53"
target_address: 10.147.102.2
- description: ""
protocol: tcp
listen_port: "53"
target_port: "53"
target_address: 10.147.102.2
listen_address: 192.168.1.200
location: none
You can also do multi port forwards:
lxc network forward port add lxdbr0 192.168.1.200 tcp 80,81,8080-8090 10.147.102.2
or multi ports to a different set of multi ports:
lxc network forward port add lxdbr0 192.168.1.200 tcp 80,81,8080-8090 10.147.102.2 90,91,9080-9090
or multi ports to a single port:
lxc network forward port add lxdbr0 192.168.1.200 tcp 80,81,8080-8090 10.147.102.2 80