Recently I installed a VPN on my PC (192.168.1.52) and I set it listen on address 0.0.0.0:1081. Then I tried to route all tcp packet from my Nintendo Switch (192.168.1.151) to the proxy by using following command:
But it did not work. So I used Wireshark to check the packet traffic on my PC, and I found that my PC do have received tcp packet on Port 1081. But It's source IP is 192.168.1.1. I did some research and changed my my command to following:
But it still did not work. The source IP of the received tcp packet was still 192.168.1.1. Now I have no idea on this issue. Could someone help me out of this problem?
Code:
iptables -t nat -A PREROUTING -s 192.168.1.151 -p tcp -j DNAT --to-destination 192.168.1.52:1081
iptables -t nat -A FORWARD -d 192.168.1.52 -dport 1081 -j ACCEPT
Code:
iptables -t nat -A PREROUTING -s 192.168.1.151 -p tcp -j DNAT --to-destination 192.168.1.52:1081
iptables -t nat -A POSTROUTING -d 192.168.1.52 -dport 1081 -p tcp -j SNAT --to-source 192.168.1.151
iptables -t nat -A FORWARD -d 192.168.1.52 -dport 1081 -j ACCEPT