Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
Please post the contents of the file "/etc/network/interfaces". –  Soviero Oct 28 '11 at 2:44
    
And a netstat -rn –  Paul Oct 28 '11 at 2:47
    
Post your routing table sudo /sbin/route -n? –  quanta Oct 28 '11 at 2:47
    
Didn't you say they were "static" IPs? Did you mean static DHCP? –  Soviero Oct 28 '11 at 3:10
1  
Um... Please replace "dhcp" with "static" in your "/etc/network/interfaces" file for both eth0 and eth1... –  Soviero Oct 28 '11 at 4:42
show 3 more comments

2 Answers

If you don't need to treat both interfaces as different a better solution would be to bond both interfaces together and split the load between them: https://help.ubuntu.com/community/UbuntuBonding

If you need to keep your current scenario take a look at this old article - http://www.linuxjournal.com/article/7291 -

The commands might be different nowadays but the idea is the same, do policy based routing based on the source IP.

I can't comment yet but i believe Kevin suggestion should work, but according to your routing table you still have two entries so it seems you haven't restarted the network after the change.

share|improve this answer
add comment

If you are okay with all traffic going through only one interface, you can simply set the default gateway setting on only one interface... For example:

Assuming you want the traffic to go through just "eth0":

auto eth0
iface eth0 inet static
    address 192.168.1.210
    netmask 255.255.255.0
    gateway 192.168.1.1

auto eth1
iface eth1 inet static
    address 192.168.1.211
    netmask 255.255.255.0

Notice the omission of the "gateway" field on the second interface?

share|improve this answer
    
Won't that just make things worse? Now if he does receive any Internet traffic on the other interface (which he can because it will respond to ARP), rp filtering will cause him to drop it on the floor. –  David Schwartz Oct 28 '11 at 3:15
    
I'll give this a go and let you know, thanks! –  Chris Drumgoole Oct 28 '11 at 3:56
    
@DavidSchwartz I've never run into that problem before, but this may end up being a learning experience... –  Soviero Oct 28 '11 at 4:00
    
Hmm, doesn't look like this is working for me. I will amend my question with the findings. –  Chris Drumgoole Oct 28 '11 at 4:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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