IP表
我 10.8.0.7 Debian
Linux服务器cent8 eth0 192.168.88.11 tun0 10.8.0.6
如何将10.8.0.6:8888端口转发到本地192.168.88.10:443机器?
启用转发
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo sysctl -w net.ipv4.ip_forward=1
echo '1' | sudo tee /proc/sys/net/ipv4/conf/eth0/forwarding ;
echo '1' | sudo tee /proc/sys/net/ipv4/conf/tun0/forwarding
sudo iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT
# forward 10.8.0.6:8888 to local 192.168.88.10:443
sudo iptables -t nat -A PREROUTING -p tcp -d 10.8.0.6 --dport 8888-j DNAT --to-destination 192.168.88.10:443
# return
sudo iptables -t nat -A POSTROUTING -p tcp --dst 192.168.88.10 -j SNAT --to-source 10.8.0.6:8888
# remove
sudo iptables -t nat -D PREROUTING 2
sudo iptables -t nat -D POSTROUTING 2
什么不起作用?