Делал всё тоже самое, но решение не помогло. После перезагрузки контроллера все правила стираются из nft list ruleset
Но мой пример не совсем совпадает с автором, у меня всё через VPN tun0
ifconfig:
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 10.87.88.21 netmask 255.255.252.0 destination 10.87.88.21
inet6 fe80::4f05:d40c:8da3:e193 prefixlen 64 scopeid 0x20
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 78043 bytes 12281294 (11.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 67996 bytes 7631200 (7.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::3d95:43aa:7ca8:93ef prefixlen 64 scopeid 0x20
ether 00:85:01:02:92:e7 txqueuelen 1000 (Ethernet)
RX packets 59493 bytes 9111978 (8.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 52472 bytes 12734057 (12.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 46
10.42.0.2 пингуется.
nft list ruleset
table ip nm-shared-eth0 {
chain nat_postrouting {
type nat hook postrouting priority srcnat; policy accept;
ip saddr 10.42.0.0/24 ip daddr != 10.42.0.0/24 masquerade
}
chain filter_forward {
type filter hook forward priority filter; policy accept;
ip daddr 10.42.0.0/24 oifname "eth0" ct state { established, related } accept
ip saddr 10.42.0.0/24 iifname "eth0" accept
iifname "eth0" oifname "eth0" accept
iifname "eth0" reject
oifname "eth0" reject
}
}
table ip nat {
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
tcp dport 5900 dnat to 10.42.0.2
tcp dport 8000 dnat to 10.42.0.2
tcp dport 20248 dnat to 10.42.0.2
tcp dport 2000 dnat to 10.42.0.2
tcp dport 8005 dnat to 10.42.0.2
tcp dport 8001 dnat to 10.42.0.2
tcp dport 8010 dnat to 10.42.0.2
}
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
ip daddr 10.42.0.2 masquerade
}
}
И магия не происходит, при подключении к VNC на 5900
Что было прописано:
sysctl net.ipv4.ip_forward=1
sysctl net.ipv4.conf.tun0.forwarding=1
nft add table ip nat
nft add chain ip nat prerouting ‘{type nat hook prerouting priority dstnat;}’
nft add rule ip nat prerouting tcp dport 5900 dnat to 10.42.0.2
nft add rule ip nat prerouting tcp dport 8000 dnat to 10.42.0.2
nft add rule ip nat prerouting tcp dport 20248 dnat to 10.42.0.2
nft add rule ip nat prerouting tcp dport 2000 dnat to 10.42.0.2
nft add rule ip nat prerouting tcp dport 8005 dnat to 10.42.0.2
nft add rule ip nat prerouting tcp dport 8001 dnat to 10.42.0.2
nft add rule ip nat prerouting tcp dport 8010 dnat to 10.42.0.2
nft add chain ip nat postrouting ‘{type nat hook postrouting priority srcnat;}’
nft add rule ip nat postrouting ip daddr 10.42.0.2 masquerade
modprobe nf_nat
Что надо сделать, чтобы проброс портов заработал и конфиг не сбрасывался?