I have a machine that serves both as a router and a server. I have several lxc containers on this machine, and want to expose them to both the LAN and WAN. Following https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/sec-configuring_port_forwarding_using_nftables I was able to successfully access the servers from both WAN and LAN machines, but not localhost/the router-server itself!
Here is the configuration that partially works:
# Created from lxc-net in debian
table inet lxc {
chain input {
type filter hook input priority filter; policy accept;
iifname "lxcbr0" udp dport { 53, 67 } accept
iifname "lxcbr0" tcp dport { 53, 67 } accept
}
chain forward {
type filter hook forward priority filter; policy accept;
iifname "lxcbr0" accept
oifname "lxcbr0" accept
}
}
# Created from lxc-net in debian
table ip lxc {
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
ip saddr 10.0.3.0/24 ip daddr != 10.0.3.0/24 counter packets 51 bytes 3745 masquerade
}
}
# This is what I added
table ip myportforwarding {
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
tcp dport 8088 dnat to 10.0.3.230
}
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
ip daddr 10.0.3.230 masquerade
}
}
I tried several options from this answer: How to configure port forwarding with nftables for a Minecraft server on Raspberry Pi?
Nothing seemed to work to enable local access to the services on 8088.
Looking at wireshark, access from LAN looks like:
192.168.1.105 -> 192.168.1.1 SYN
10.0.3.1 -> 10.0.3.230 SYN
...
Access from the same machine:
192.168.1.1 -> 192.168.1.1 SYN
192.168.1.1 <- 192.168.1.1 FIN!
I'm not too familar with nft or iptables, so I'm sure there is something I'm missing
