Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following rule:

iptables -t nat -A PREROUTING -d -j DNAT --to-destination

Problem is that this rule affects some programs and I want this rule to be active only for a specific port like 443.

Is it possible to do that? I mean, everything else that tries to connect to on a different port than 443 should not be affected by this rule.

many thanks.

share|improve this question
up vote 1 down vote accepted


iptables -t nat -A PREROUTING -d --sport 443 -j DNAT --to-destination
share|improve this answer
Damn. The answer above got it before me. – Joseph Redfern Nov 1 '10 at 19:33
thanks mate. seems to fix it – Ian P. Nov 1 '10 at 20:12
Weird that --sport instead of --dport fixed it. That too without -m tcp. – Saurabh Barjatiya Nov 2 '10 at 8:15

Add -p tcp --dport 443 to your command, and then it will only match TCP packets with destination port = 443.

share|improve this answer

Your Answer


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.