0

Sorry, I'm a noob in iptables.

I have a VPN app which binds on local port 1080, while it goes to destination port 1194 (openvpn). The app does not support privileged port binding (which needs root, of which I have). I want the app to bind on local port 25. I have browsed Google and the answer seems to be iptables. I have seen many posts, of which many say the SNAT target is the one I should use.

I have tried this code:

iptables -I POSTROUTING -o wlan0 -t nat -p tcp --destination 195.123.216.159 -m tcp --dport 1194 -j SNAT --to-source 192.168.43.239:25

And these:

iptables -I FORWARD -p tcp -d 192.168.43.239 -m tcp --dport 25 -j ACCEPT

iptables -I FORWARD -p tcp -s 192.168.43.239 -m tcp --sport 25 -j ACCEPT

iptables -I OUTPUT -o wlan0 -p tcp -m tcp --sport 25 -j ACCEPT

iptables -I INPUT -i wlan0 -p tcp -m tcp --dport 25 -j ACCEPT

What I want is to make the output to be something like this when I run the netstat command:

tcp       0      0 192.168.43.239:25      195.123.216.159:1194      ESTABLISHED

But instead, after running all the codes, the output to netstat becomes this:

tcp       0      0 192.168.43.239:1080      195.123.216.159:5000      ESTABLISHED

Is it impossible to change binding port using iptables? Please help me to understand the concepts of networking.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Silent
  • 31
  • 6

1 Answers1

0

Turns out iptables was just doing its job correctly. Translated packets turn out to not be tracked by netstat. I was lost and completely didnt understand that iptables doesnt alter ip v6 traffic of which the app was using. And the forward rules where not necessary since the chain policy was to accept the packets.

Silent
  • 31
  • 6