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 1.2.3.0/8 -j DNAT --to-destination 192.168.0.0/8 -o eth0
iptables -t nat -A OUTPUT -p all -d 3.2.1.0/8 -j DNAT --to-destination 192.168.0.0/8 -o eth1
Example:
eth0 has the ip of 192.168.0.1 on a network with the range 192.168.0.*
eth1 has the ip of 192.168.0.8 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?
Your question is not clear, but assuming you want to route your 1.2.3.4 traffic to one NIC and 4.3.2.1 to another than you need to update you routing table using route command.
Example :
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.