Linux – Multiple ethernet interfaces

linuxlinux-networkingnetworking

I have a two network cards, configured like this:

eth0      Link encap:Ethernet  HWaddr 00:19:d1:31:08:e8  
          inet addr:192.168.5.104  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::219:d1ff:fe31:8e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4564126 errors:590 dropped:0 overruns:0 frame:329
          TX packets:9707383 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1151788275 (1.0 GiB)  TX bytes:189318786 (180.5 MiB)
          Interrupt:20 Memory:e0300000-e0320000 

eth1      Link encap:Ethernet  HWaddr 00:e0:4c:51:0d:55  
          inet addr:85.255.103.4  Bcast:85.255.103.255  Mask:255.255.255.0
          inet6 addr: fe80::2e0:4cff:fe51:d55/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5466 errors:0 dropped:0 overruns:0 frame:0
          TX packets:499 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:518961 (506.7 KiB)  TX bytes:34236 (33.4 KiB)
          Interrupt:22 Base address:0x1000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:136 errors:0 dropped:0 overruns:0 frame:0
          TX packets:136 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:15556 (15.1 KiB)  TX bytes:15556 (15.1 KiB)

The ip route:

$ ip route
192.168.5.0/24 dev eth0  proto kernel  scope link  src 192.168.5.104 
85.255.103.0/24 dev eth1  proto kernel  scope link  src 85.255.103.4 
default via 192.168.5.1 dev eth0 
default via 85.255.103.1 dev eth1

When I ping the ip address of eth1, i get no response.

With tcpdump I figured that all the ICMP echo requests sent to eth1 are answered through the eth0 interface.

How can I achieve that both interfaces work correctly? If I ping eth1 it should return answer on eth1 as well.

eth0 has a faster internet connection, I just want to keep eth1 around as well and go through it when the application binds to that specific ip.

Best Answer

Remove the gateway defined for eth0 (192.168.5.1). If you need multiple default routes you'll have to use iproute2 to create a policy for it.