0

It's either I have a fundamental misunderstanding on how interfaces are suppose to work or I've done something oddly wrong.

I have two interfaces:

  • eno1: 10.6.59.203/24 (gateway 10.6.59.1)
  • eno2: 192.168.5.100/24 (gateway 192.168.5.1)

If I unplug one cable and reboot, regardless of cable, it will have internet.

However, if I have them both plugged in, only one interface works (defaults to eno2). For example:

ping google.com -I eno2   # works
ping google.com -I eno1   # hangs forever

How do I get both statements above to work?

my /etc/network/interface:

# The loopback network interface
auto lo
iface lo inet loopback

allow-hotplug eno2
iface eno2 inet dhcp

allow-hotplug eno1
iface eno1 inet dhcp

my route:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.5.1     0.0.0.0         UG    0      0        0 eno2
10.6.59.0       0.0.0.0         255.255.255.0   U     0      0        0 eno1
192.168.5.0     0.0.0.0         255.255.255.0   U     0      0        0 eno2

Update

I found the way to fix this is route add default gw 10.6.59.1 eno1. However, how do I properly do this on start-up (possibly by just editing /etc/network/interfaces).

Furthermore, now that I have 2 default destinations, how does linux know which one to use by default?

4

You only have one default gateway, thus outgoing packets will only be sent through that one; if you want to be able to use both connections, you need to manually add another default gateway (i.e. a route to 0.0.0.0) using the other interface's gateway.

But please note that this will not use both connections at the same time; this is just not possible out of the box. One of the connections will be always used, the other one will only be used if the primary one fails; the preferred route is defined by the "metric" parameter.

  • Thanks. This solved my problem. See my update, though – Sanchke Dellowar Aug 18 at 21:55
  • The preferred route is defined by the metric; the route with the lowest metric will be used, unless it's unavailable. – Massimo Aug 18 at 21:58
1

By default linux routes outgoing packets by destination address only.
You need routing based on destination and source addresses.

https://superuser.com/questions/376667/how-to-route-only-specific-subnet-source-ip-to-a-particular-interface

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.