Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having trouble prerouting port 2222 to the destination port 22. The other rules seems to work, but can't figure out why this rule doesn't. This is my iptable-config:

# Generated by iptables-save v1.4.4 on Wed Jul 20 10:49:02 2011
*mangle
:PREROUTING ACCEPT [418489:457965157]
:INPUT ACCEPT [418489:457965157]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [191243:252779269]
:POSTROUTING ACCEPT [191243:252779269]
COMMIT
# Completed on Wed Jul 20 10:49:02 2011
# Generated by iptables-save v1.4.4 on Wed Jul 20 10:49:02 2011
*nat
:PREROUTING ACCEPT [345:20684]
:OUTPUT ACCEPT [372:27203]
:POSTROUTING ACCEPT [372:27203]
-A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 
-A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8080 
-A PREROUTING -i eth0 -p tcp -m tcp --dport 2222 -j REDIRECT --to-ports 22
COMMIT
# Completed on Wed Jul 20 10:49:02 2011
# Generated by iptables-save v1.4.4 on Wed Jul 20 10:49:02 2011
*filter
:INPUT ACCEPT [418489:457965157]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [191243:252779269]
COMMIT
# Completed on Wed Jul 20 10:49:02 2011
share|improve this question
    
If you redirect ports on the same machine, why don't you want just to use port 22? Or why don't you want to reconfig sshd to listen port 2222? –  slimsuperhero Mar 11 '13 at 12:44
1  
He might want them on both, but without the hassle of running the daemon twice. I do the same thing on my mail server to simulate sendmail listening on port 587 without actually running two different sendmails. –  MadHatter Mar 11 '13 at 12:48
1  
Can we see some evidence that it doesn't work? Plus comparable evidence that at least one of the others does? –  MadHatter Mar 11 '13 at 12:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.