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 am trying to set up a redirect for 443 to 8443 (non-root app can not use privileged port) using the following:

iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443

However, when trying to connect on 443 (via localhost), I am getting a 'connection refused'. 8443 is open and functioning. I assume a 'connection refused' issue precludes response packets being dropped, as that would result in a timeout.

No other rules exist for filter, nat, mangle, or raw.

Distribution information:

# rpm -q iptables
iptables-1.3.5-9.1.el5
# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
share|improve this question
    
Found the answer here. I needed to add a separate rule for loopback to work: iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 443 -j REDIRECT --to-ports 8443 –  Ben Jan 15 '13 at 23:22
3  
This should be an answer, not a comment. –  Michael Hampton Jan 15 '13 at 23:26
    
Thanks for the tip. but as I am not yet privileged enough to answer my own questions in a timely manner, a comment will have to suffice. –  Ben Jan 16 '13 at 3:31

1 Answer 1

PREROUTING is for NATting packets before they are routed. Locally-generated packets are OUTPUTted, not routed. So use the OUTPUT chain.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.