1

I want to use iptables for provide NAT translation and forward the packets out a different interface.

The network set-up is as follows:

Alias:

eth0:220 with IP address 10.1.1.220 / 255.255.252.0

eth0:221 with IP address 10.1.1.221 / 255.255.252.0

tagged VLAN:

eth1.220 with ip address 192.168.0.1/24

eth1.221 with ip address 192.168.0.1/24

I understand that the following lines with provide the NAT translation:

iptables -t nat -A PREROUTING -i eth0:220 -d 10.1.1.220 -j DNAT --to-destination 192.168.0.23/24 
iptables -t nat -A PREROUTING -i eth0:221 -d 10.1.1.221 -j DNAT --to-destination 192.168.0.23/24

But how do I specify which interface the packets to go out on?

eth0:220 needs to leave eth1.220 in order for the packets to become tagged with the correct VLANID.

using -o eth1.220 is not allowed with PREROUTING

does anything need to be done for traffic from eth1.220 to the gateway at 10.1.0.1?

Adding some more information: The idea is that a tester will be connected to the 10.1.0.0/22 network and when they enter in 10.1.1.220 in the webbrowser the website at IP address 192.168.0.23 on VLAN220 will be displayed. This will allow them to change the device under test (DTU) without having to change the default IP address of the DTU. There will about 200 of these VLANs.

  • Hy @kenneth-robinson, there are other interface in the network 192.168.0.0/24? – Franciscon Santos Apr 23 '15 at 13:34
  • Where does 10.1.0.1 come from? You only mention it at the very end of your question. It's also really wierd to have two interfaces with the exact same IP address, I'm wondering whether you some basic misconception on how networking works. – wurtel Apr 23 '15 at 13:48
  • Can you post your routing table? – Khaled Apr 23 '15 at 13:50
  • Edit your question, and this time post _all_ relevant information (such as the missing firewall rules), and do not attempt to obfuscate [things which do not need to be obfuscated](http://meta.serverfault.com/q/963/126632). – Michael Hampton Apr 23 '15 at 13:53
  • Fransiscon - there are only two IP address on the 192.168.0.0/24 network (192.168.0.23 and 192.168.0.1) wurtel - 10.1.0.1 is the default gateway (access to internet) for 10.1.0.0/22 network. the two interfaces are on different VLANs so they can have the same ip address – kenneth Robinson Apr 23 '15 at 17:40

0 Answers0