1

For some reason my eth0 does not have internet on reboot sometimes. I am using a static ip. I can ping my gateway, but I am unable to ping dns servers, or anything out of my network. It seems that when my internet does work(Usually but just restarting enough times), my /etc/resolv.conf has a nameserver in it. It is empty when I have no internet access. I believe something is overwriting my interfaces settings sometimes on boot. Any help would be appreciated. I am running Ubuntu Server 12.04 64bit

/etc/network/interfaces:

auto lo
iface lo inet loopback


 auto eth0
 iface eth0 inet static
     address 173.213.192.234
     netmask 255.255.255.248
     network 173.213.192.232
     broadcast 173.213.192.239
     gateway 173.213.192.233
     dns-nameservers 8.8.8.8

 auto eth1
 iface eth1 inet static
     address 10.0.0.106
     netmask 255.255.255.0
     gateway 10.0.0.1
Eumcoz
  • 135
  • 1
  • 1
  • 5
  • 2
    You can't have more than one default gateway. What is that eth1 network? – Eric Carvalho Jun 25 '13 at 21:35
  • eth1 is a local network. eth0 points to the outside network(internet). – Eumcoz Jun 25 '13 at 21:39
  • 1
    @user1221444 Well, that's not what you tell Ubuntu here by providing two gateways! :) By providing two default routes it will be very random about which one it will actually use to connect to the outside world. – gertvdijk Jun 25 '13 at 21:40
  • Does 10.0.0.1 exist? Do you need it to access another network? – Eric Carvalho Jun 25 '13 at 21:40
  • How can I set it up so that my local traffic will go through eth1 and all other traffic will go through eth0? – Eumcoz Jun 25 '13 at 21:40
  • 1
    @user1221444 Again, remove the gateway from the `eth1` definition. If you need specific networks to be routed over `10.0.0.1` you'll have to set it up manually. You don't have to do anything for 10.0.0.0/24 as that's on the local link of eth1. – gertvdijk Jun 25 '13 at 21:41
  • Okay, I removed the gateway for eth1. I did a `/etc/init.d/networking restart`. My pings no longer hang when pinging google.com, but I get a `unknown host google.com` message, which leads me to believe I still have a problem with my nameserver not being there. Any clue about that? – Eumcoz Jun 25 '13 at 21:47

1 Answers1

3

Try this interfaces file:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 173.213.192.234
    netmask 255.255.255.248
    gateway 173.213.192.233
    dns-nameservers 8.8.8.8

auto eth1
iface eth1 inet static
    address 10.0.0.106
    netmask 255.255.255.0
    up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.0.0.1
    up route add -net 172.16.0.0 netmask 255.240.0.0 gw 10.0.0.1
    up route add -net 192.168.0.0 netmask 255.255.0.0 gw 10.0.0.1

This will redirect all local traffic to 10.0.0.1 and Internet to 173.213.192.233.

Eric Carvalho
  • 53,609
  • 102
  • 137
  • 162