Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 a static 1:1 NAT setup in iptables which excludes a the larger subnet (so that NETMAP hosts can still get to other local hosts which are not static NAT) like so:

-A PREROUTING --destination -j NETMAP --to
-A POSTROUTING --source ! -d -j NETMAP --to

I would also like to exclude public facing IP addresses so that static NAT hosts can still reach the public IP address of another static NAT host on the machine. But multiple negated destinations do not seem to be supported. This throws an error:

-A PREROUTING --destination -j NETMAP --to
-A POSTROUTING --source ! -d ! -d -j NETMAP --to

How can I setup iptables to allow static NAT NETMAPed hosts to reach other public addresses on the iptables machine?

share|improve this question
up vote 3 down vote accepted

You'll need to use an additional chain, and RETURN before the NETMAP rules.

-N NETMAP_src101020
-A NETMAP_src101020 -d -j RETURN
-A NETMAP_src101020 -d -j RETURN
-A NETMAP_src101020 -j NETMAP --to
-A PREROUTING --source -j NETMAP_src101020
-A PREROUTING --destination -j NETMAP --to

So any packets from is sent into the NETMAP_src101020 chain. If the packet is destined for then we RETURN from that chain; same if the packet is destined to Only then does it get to the actual NETMAP rule.

Hope this makes enough sense; I think it's easier to explain by showing you than some long-winded explanation.

share|improve this answer
This makes a lot of sense. I will test it out tomorrow. – Andy Shinn Dec 18 '12 at 3:12
Thanks, this ultimately does do what I asked and answers the question. However, it ultimately didn't fix my underlying problem that I thought was because of this. I will open a new question for my larger problem related to this. – Andy Shinn Dec 19 '12 at 18:26

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.