2
1
So, I've got two NICs:
eth0
eth1
and I have multiple IP addresses assigned to each:
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 10.0.0.194
netmask 255.255.255.0
gateway 10.0.0.1
network 10.0.0.0
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
address 10.0.0.253
netmask 255.255.255.0
auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
address 10.0.0.252
netmask 255.255.255.0
auto eth0:2
allow-hotplug eth0:2
iface eth0:2 inet static
address 10.0.0.251
netmask 255.255.255.0
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 10.0.0.74
netmask 255.255.255.0
gateway 10.0.0.1
network 10.0.0.0
auto eth1:0
allow-hotplug eth1:0
iface eth1:0 inet static
address 10.0.0.105
netmask 255.255.255.0
auto eth1:1
allow-hotplug eth1:1
iface eth1:1 inet static
address 10.0.0.104
netmask 255.255.255.0
auto eth1:2
allow-hotplug eth1:2
iface eth1:2 inet static
address 10.0.0.106
netmask 255.255.255.0
I've also setup ip route like so:
sudo ip route add 10.0.0.0/24 dev eth0 table eth0
sudo ip route add default via 10.0.0.1 dev eth0 table eth0
sudo ip route add 10.0.0.0/24 dev eth1 table eth1
sudo ip route add default via 10.0.0.1 dev eth1 table eth1
sudo ip rule add from 10.0.0.194 table eth0
sudo ip rule add from 10.0.0.74 table eth1
Now when I execute the following commands, everything works fine I get back my external IP:
curl --interface eth0 http://ipecho.net/plain ; echo
curl --interface eth0:0 http://ipecho.net/plain ; echo
curl --interface eth0:1 http://ipecho.net/plain ; echo
curl --interface eth0:2 http://ipecho.net/plain ; echo
curl --interface eth1 http://ipecho.net/plain ; echo
However, when I run:
curl --interface eth1:0 http://ipecho.net/plain ; echo
Nothing happens. I've obviously messed up my routes or something. Can anyone help me out? Thanks.
ip route
default via 10.0.0.1 dev eth0
10.0.0.0/24 dev eth0 proto kernel scope link src 10.0.0.194
10.0.0.0/24 dev eth1 proto kernel scope link src 10.0.0.74
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
EDIT:
So I found this, which is what I'm trying to do however, I don't want to specify any subnets. I just want it to round-robin the requests.
Have you set reverse path filtering off ? Its possible that traffic for eth1:0 is leaving one interface and coming back on the other. – davidgo – 2015-12-25T22:38:14.250
It sounds like you want a strong host model, which Linux just doesn't do.
– David Schwartz – 2015-12-25T22:41:00.547Read my answer here: https://superuser.com/questions/1056054/using-dhcp-to-get-two-different-ip-addresses-for-two-nics-on-one-machine/1056060#1056060 - if you are not interested in bonding the two interfaces (making them look like 1 to the OS and also the receiving end), then it should explain things.
– LawrenceC – 2016-04-29T19:59:40.913I'm guessing you are statically assigning your IP addresses, no? If you are, wouldn't you agree that posting the contents of /etc/network/interfaces is more informative than the output of
ifconfig
? I'd like to see how you actually have it manually configured. – jason – 2014-03-22T21:37:18.550Wich distribution are you using? – Nils – 2014-03-23T22:00:33.360
What happens when you add explicit routing rules for all outgoing IP addresses? – Daniel B – 2014-03-24T13:03:48.437
Where is your initial connection(s) to the Internet? Which interface(s)? What are configuration details for such interface(s). – jason – 2014-03-24T23:53:49.730
Please explain why you have those IPs assigned. BTW:
ip route get $IP
will show you which interface will be used for that target IP. – Nils – 2014-03-28T21:32:44.363Because its on AWS VPC – Hugh – 2014-03-28T21:46:52.980
Whatever it is you are trying to do, this is not the way to do it. Linux fundamentally follows the weak end system model (IP addresses belong to machines) and your configuration only makes sense under a strong end system model (IP addresses belong to interfaces).
– David Schwartz – 2014-03-28T21:55:26.523Follow the bonding link in my answer. Everything is explained there... – Nils – 2014-04-03T14:01:24.560