[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

2 NICs and the source ip address



Hi,

I'm wondering whether there is a simple and preferred way to configure
the ip parameters for the following situation:

Host A has 2 NICs (say eth0 and eth1), where eth0 is connected to
the LAN and is given the ip address 1.2.3.4. The DNS entry
of host A points to that ip address. In addition, the second interface
eth1 of host A is dedicated to some "special" kind of data
traffic (say, nfs traffic to a fileserver, or a network block device
located on host B). Therefore the private IP address 10.0.0.1 is
assigned to eth1. So you end up with a
/etc/network/interfaces config file like

auto eth0
iface eth0 inet static
    address 1.2.3.4
    network 1.2.3.0
    netmask 255.255.255.0
    broadcast 1.2.3.255
    up route add default gw 1.2.3.254 dev eth0

auto eth1
iface eth1 inet static
    address 10.0.0.1
    network 10.0.0.0
    netmask 255.0.0.0
    broadcast 10.255.255.255

This will result in the correct routing table. But there is no
control of the source ip address leaving eth0 or eth1. It seems
preferable that all packages going through eth0 are given the
source ip address 1.2.3.4 and all the packages running through
eth1 have source ip address 10.0.0.1 . This is, however not
the case. E.g. IP packages leaving through eth1 are given the source
ip address 1.2.3.4 and therefore the response is arriving
through eth0.

ARP is another issue:  ARP requests to 1.2.3.4 should be answered
with the MAC address of eth0 and vice versa.

Is there an easy and preferred way to accomplish this goal (which
seems to be not that uncommon)? Should I use iproute2 or even
iptables/NAT ?

Thanks for any hint, Thomas




Reply to: