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
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.
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":
Notice the omission of the "gateway" field on the second interface?
This problem is not unique.This is a problem of Routing.
Run :
route -n
to show your routing table.My Routing table is like this :
It's OK because I have only 1 Default Gateway ( it is the last line) But your Routing Table has 2 Default Gateway like this :
So, when your Server connect to the internet it use these two gateway ( two line of internet) rotately. This caused the SSH Server raise the exception like this in /var/log/secure
The Solution is : Remove 1 Default Gateway.
(Change the IP match your System) Good luck
This is possibly an issue with the gateway. Try adding a new gateway:
route add default gw 192.168.x.x
and commenting out the 'gateway' on the static networks.