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

I have two network adapters that use the same ip range, but are different networks.

I tried this but it didn't work:

iptables -t nat -A OUTPUT -p all -d -j DNAT --to-destination -o eth0
iptables -t nat -A OUTPUT -p all -d -j DNAT --to-destination -o eth1


eth0 has the ip of on a network with the range 192.168.0.*

eth1 has the ip of on a separate network with the range 192.168.0.*

1.2.3.* = 192.168.0.* through eth1

3.2.1.* = 192.168.0.* through eth0

Is this something I can do with iptables?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Your question is not clear, but assuming you want to route your traffic to one NIC and to another than you need to update you routing table using route command.

Example :

route add -net netmask dev eth1
route add -net netmask dev eth0
share|improve this answer
This won't do what the OP seems to want. He wants a way to use NAT so that he can reach two different machines, both themselves numbered, with different IP addresses as seen from his machine. –  David Schwartz Nov 5 '11 at 18:59
"both themselves numbered" where does it say that? –  Andrey Nov 5 '11 at 19:02
That was just an example. I picked 50 arbitrarily to try to explain what I mean. He has two networks that both use the same IP address range, and he wants to remap those addresses into distinct IP ranges as seen from his machine. That's why he's using NAT. –  David Schwartz Nov 5 '11 at 19:05
What I understand is that he has two physical LANs that are connected to his machine via two separate NICs. Each LAN has IP addressing. If this correct? –  Andrey Nov 5 '11 at 19:05
Yes. So that means that could mean two different machines. He wants to be able to access both of them, one as and the other as -- that's why he's using DNAT. –  David Schwartz Nov 5 '11 at 19:09

You would either have to write code specifically to do this or add 512 individual NAT rules. The DNAT module treats multiple IPs as a round-robin, not a mapping.

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.