Solved nat routing for port 22

September 29, 2013 at 11:25:45
Specs: ubuntu 10.10, i5
I'm trying to route all 8022 traffic to 22 ssl. What do I have wrong here?

iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 8022 -j DNAT --to-destination 127.0.0.1:22
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 8022 -j ACCEPT


See More: nat routing for port 22

Report •

#1
October 4, 2013 at 18:17:45
✔ Best Answer
Try this rule:

iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 8022 -j REDIRECT --to-port 22


Report •

#2
October 5, 2013 at 10:26:15
hmm, didnt seem to get it. I also tried clearing the tables a head of time encase I had something in there causing issues.

Report •

#3
October 5, 2013 at 12:28:21
I don't know, why this has to be redirected to 127.0.0.1.
It normally should go to the IP address of, in your case, eth0.

If you need to use external port 8022, redirecting to port 22, the rule shown in #1 works perfectly.


Report •

Related Solutions

#4
October 5, 2013 at 13:00:29
Its a leased ip, so I was using 127.0.0.1 as it makes it work when the IP changes. If you say a direct to port works, that is good enough for me. thx for your help.

message edited by ulaoulao


Report •

Ask Question