Ubuntu Server, 2 Ethernet Devices, Same Gateway - Want to force internet traffic through 1 device (or at least allow it to work!)

Posted by Chris Drumgoole on Server Fault See other posts from Server Fault or by Chris Drumgoole
Published on 2011-10-28T02:40:06Z Indexed on 2013/11/10 22:02 UTC
Read the original article Hit count: 230

Filed under:
|
|
|

I have a Ubuntu 10.04 Server with 2 ethernet devices, eth0 and eth1.

  • eth0 has a static IP of 192.168.1.210
  • eth1 has a static IP if 192.168.1.211

The DHCP server (which also serves as the internet gateway) sits at 192.168.1.1.

The issue I have right now is when I have both plugged in, I can connect to both IPs over SSH internally, but I can't connect to the internet from the server. If I unplug one of the devices (e.g. eth1), then it works, no problem. (Also, I get the same result when I run sudo ifconfig eth1 down).

Question, how can I configure it so that I can have both devices eth0 and eth1 play nice on the same network, but allow internet access as well? (I am open to either enforcing all inet traffic going through a single device, or through both, I'm flexible).

From my google searching, it seems I could have a unique (or not popular) problem, so haven't been able to find a solution. Is this something that people generally don't do? The reason I want to make use of both ethernet devices is because I want to run different local traffic services on on both to split the load, so to speak...

Thanks in advance.

UPDATE

Contents of /etc/network/interfaces:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# The secondary network interface
#auto eth1
#iface eth1 inet dhcp

(Note: above, I commented out the last 2 lines because I thought that was causing issues... but it didn't solve it)

netstat -rn

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     192.168.1.1     255.255.255.0   UG        0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0

UPDATE 2

I made a change to the /etc/network/interfaces file as suggested by Kevin. Before I display the file contents and the route table, when I am logged into the server (through SSH), I can not ping an external server, so this is the same issue I was experiencing that led to me posting this question.

I ran a /etc/init.d/networking restart after making the file changes.

Contents of /etc/network/interfaces:

# The loopback network interface auto lo iface lo inet loopback

# The primary network interface 
auto eth0 iface eth0 inet dhcp
    address 192.168.1.210
    netmask 255.255.255.0
    gateway 192.168.1.1

# The secondary network interface 
auto eth1 iface eth1 inet dhcp
    address 192.168.1.211
    netmask 255.255.255.0

ifconfig output

eth0      Link encap:Ethernet  HWaddr 78:2b:cb:4c:02:7f
          inet addr:192.168.1.210  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::7a2b:cbff:fe4c:27f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6397 errors:0 dropped:0 overruns:0 frame:0
          TX packets:683 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:538881 (538.8 KB)  TX bytes:85597 (85.5 KB)
          Interrupt:36 Memory:da000000-da012800

eth1      Link encap:Ethernet  HWaddr 78:2b:cb:4c:02:80
          inet addr:192.168.1.211  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::7a2b:cbff:fe4c:280/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5799 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:484436 (484.4 KB)  TX bytes:1184 (1.1 KB)
          Interrupt:48 Memory:dc000000-dc012800

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:635 errors:0 dropped:0 overruns:0 frame:0
          TX packets:635 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:38154 (38.1 KB)  TX bytes:38154 (38.1 KB)

netstat -rn

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth1
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0

© Server Fault or respective owner

Related posts about ubuntu

Related posts about networking