7

I'm trying to set up two network adapters in Ubuntu (server edition) 9.10. One for the public internet, the other a private LAN.

During the install, I was asked to pick a primary network adapter (eth0 or eth1). I chose eth0, gave the installer the details listed below in the contents of /etc/network/interfaces, and carried on. I've been using this adapter with these setting for the last few days, and every thing's been fine.

Today, I decide it's time to set up the local adapter. I edit the /etc/network/interfaces to add the details for eth1 (see below), and restart networking with sudo /etc/init.d/networking restart.

After this, attempting to ping the machine using its external IP address fails, but I can ping its local IP address.

If I bring eth1 down using sudo ifdown eth1, I can successfully ping the machine via its external IP address again (but obviously not its internal IP address). Bringing eth1 back up returns us to the original problem state: external IP not working, internal IP working.

Here's my /etc/network/interfaces (I've removed the external IP information, but these settings are unchanged from when it worked)

rob@rhea:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary (public) network interface
auto eth0
iface eth0 inet static
        address xxx.167.218.118
        netmask 255.255.255.240
        network xxx.167.218.112
        broadcast xxx.167.218.127
        gateway xxx.167.218.126

# The secondary (private) network interface
auto eth1
iface eth1 inet static
        address 192.168.99.4
        netmask 255.255.255.0
        network 192.168.99.0
        broadcast 192.168.99.255
        gateway 192.168.99.254

I then do this:

rob@rhea:~$ sudo /etc/init.d/networking restart
 * Reconfiguring network interfaces...                                   [ OK ]
rob@rhea:~$ sudo ifup eth0
ifup: interface eth0 already configured
rob@rhea:~$ sudo ifup eth1
ifup: interface eth1 already configured

Then, from another machine:

C:\Documents and Settings\Rob>ping xxx.167.218.118

Pinging xxx.167.218.118 with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for xxx.167.218.118:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

Back on the Ubuntu server in question:

rob@rhea:~$ sudo ifdown eth1

... and again on the other machine:

C:\Documents and Settings\Rob>ping xxx.167.218.118

Pinging xxx.167.218.118 with 32 bytes of data:

Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63
Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63
Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63
Reply from xxx.167.218.118: bytes=32 time<1ms TTL=63

Ping statistics for xxx.167.218.118:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

So... what am I doing wrong?

SOLVED The fix first to remove the gateway information from the eth1 stanza (as MikeyB suggested) and then remove the route for eth1's network address from the routing table as such:

sudo route del -net 192.168.99.0 netmask 255.255.255.0 dev eth1

4
  • With them both up, can you ping the internal from the internal machine and the external from machine external to your network?
    – McJeff
    Apr 6, 2010 at 2:55
  • @McJeff - no. With them both up I can't ping the external IP address either internally or from a SliceHost VPS
    – Rob
    Apr 6, 2010 at 2:59
  • Can you post netstat -rn and ip route list output? Sounds like an asym. routing whoops to me.
    – McJeff
    Apr 6, 2010 at 15:19
  • was experiencing a similar concern and this thread helped greatly -- thanks all! one further question: would the route del be necessary on restart after removing the second gateway entry in /etc/network/interfaces?
    – Nathan
    Nov 6, 2012 at 17:21

1 Answer 1

4

You almost certainly shouldn't have two default gateways.

Try removing the default gateway from the eth1 stanza and see if that helps.

3
  • Please post the output of ip addr and ip route with both interfaces up. And you only need to sanitize the first octet of your IP address.
    – MikeyB
    Apr 6, 2010 at 17:24
  • Thanks Mikey - removing the gateway from the eth1 stanza makes the external IP pingable from outside the network, but it's still not working from inside. I've added the requested information
    – Rob
    Apr 7, 2010 at 4:09
  • Ah! It looks you have some asymmetric routing happening. When you access xxx.167.218.118 from another machine on 192.168.99.0/24, does that request get NATted? If so, that's your problem. No need to NAT. But given that, your solution of removing the network route from eth1 will work. You could also change the internal address to a /32 address.
    – MikeyB
    Apr 7, 2010 at 19:07

You must log in to answer this question.