11

How can I change the default route to utilize eth1 (DHCP), instead of eth0 (static)? I want this to be a permanent solution persistent through reboots.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         RT-C0C1C0CF879F 0.0.0.0         UG    100    0        0 eth0
10.0.0.0        *               255.255.255.0   U     0      0        0 eth0
1.1.1.0         *               255.255.240.0   U     0      0        0 eth1

I want the direct route (eth1) to be default, not through the NAT.

Using Ubuntu 12.04

Andrew B
  • 32,588
  • 12
  • 93
  • 131
Jon Skarpeteig
  • 951
  • 2
  • 14
  • 29

1 Answers1

14

I found the answer in: http://xmodulo.com/2012/03/how-to-set-default-route-in-linux.html


Removing any unnecessary default route leveraging post-up command in /etc/network/interfaces as follows. This will enable default route through eth0

$ sudo vi /etc/network/interfaces

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug eth1
iface eth1 inet dhcp
post-up route del default dev $IFACE
Jon Skarpeteig
  • 951
  • 2
  • 14
  • 29