I occasionally have trouble with an ubuntu VM I set up for testing developement work - it occasionally becomes inaccessible to ssh, can't connect to archive.ubuntu.com for updates, etc. It has two network interfaces, an external one with a public IP eth0, and and internal one eth1 with a 10.0.x.x IP for talking to other VMs in the hypervisor group.

I noted today after booting it and being unable to ssh in and apt-get update (so I log in via the web console to debug), that when I try to ping example.com, it tries to do so via eth1 (presumably because eth0 has no connectivity, despite being up according to ifup)

If I do a traceroute it does go all the way to the datacenter. sshd is verified to be running. VM firewall accepting traffic on port 22 for eth0. Here's an extract from iptables -S:

-A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT
-A OUTPUT -s eth0 -p tcp -m tcp --sport 22 -j ACCEPT

What's really confusing is that the problem isn't deterministically reproducible. I can get a lucky boot and connectivity will work, but sometimes, without touching the settings, it doesn't. Any ideas on how to debug this?

Edit: extract from /etc/network/interfaces - no dhcp. I'm terrible at networking, so I wanted to check: is there anything here that indicates weird routing preferences?

auto eth0
iface eth0 inet static
    address x.x.x.x
    broadcast x.x.x.127
    network x.x.x.0
    gateway  x.x.x.1

auto eth1
iface eth1 inet static
    address 10.0.x.x

Should I add the following lines to eth0?

up route add x.x.x.1 dev eth0
up route add default gw x.x.x.1
  • Without error logs, ifconfig outputs when down, traceroutes and interface configuration details, the answer can be quite broad. – Rui F Ribeiro Jun 10 '16 at 10:20
  • 1
    If the machine tries to use the 10.0.x.x interface for internet traffic, then you've almost certainly got a DHCP server on that network which is advertising a default gateway, and this is just a simple race condition of which DHCP server responds first. Either configure that DHCP server not to send a default route, or configure your client to ignore it. – Patrick Jun 10 '16 at 12:00
  • I've added /etc/network/interfaces - it's not explicitly using dhcp. Is there anything wrong with it? – Escher Jun 10 '16 at 13:06
  • Oh, I made a bad assumption. I assumed you wouldn't have put a default gateway statement on 2 static interface definitions. Yeah, don't do that. Remove one of them. – Patrick Jun 11 '16 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.