lunedì 12 dicembre 2016

Ubuntu Multiple interfaces on the same subnet

7 down vote accepted

OK, it is working, and for referencing here is how I did it, hopefully someone will find it useful.
I found the solution on the following sites:
1- Multiple interfaces on the same subnet 2- Two network interfaces and two IP addresses on the same subnet in Linux
And the website that i referenced in the question as well.
suppose I have two IP addresses: 7.7.7.4 & 7.7.7.5 on network 7.7.7.0 and they have a gateway 7.7.7.1
I enabled ARP filtering:
# sysctl -w net.ipv4.conf.all.arp_filter=1
# echo "net.ipv4.conf.all.arp_filter = 1" >> /etc/sysctl.conf
And the I configured /etc/network/interfaces as following:
    # The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
   address 7.7.7.4
   network 7.7.7.0
   netmask 255.255.255.0
   broadcast 7.7.7.255
   up ip route add 7.7.7.0/24 dev eth0 src 7.7.7.4 table eth0table
   up ip route add default via 7.7.7.1 dev eth0 table eth0table
   up ip rule add from 7.7.7.4 table eth0table
   up ip route add 7.7.7.0/24 dev eth0 src 7.7.7.4

auto eth1
iface eth1 inet static
   address 7.7.7.5
   network 7.7.7.0
   netmask 255.255.255.0
   broadcast 7.7.7.255
   up ip route add 7.7.7.0/24 dev eth1 src 7.7.7.5 table eth1table
   up ip route add default via 7.7.7.1 dev eth1 table eth1table
   up ip rule add from 7.7.7.5 table eth1table
   up ip route add default via 7.7.7.1 dev eth1
   up ip route add 7.7.7.0/24 dev eth1 src 7.7.7.5
And I added the following two lines to /etc/iproute2/rt_tables
10 eth0table
20 eth1table

Nessun commento: