0

I have a Debian Jessie box with 2 interfaces. I want eth1 to route public traffic on public static IP 1.2.3.4, and eth0 to route mgmt traffic on 192.168.0.55, so I edited /etc/network/interfaces to look like:

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth1
iface eth1 inet static
        address 1.2.3.4
        netmask 255.255.255.0
        gateway 1.2.3.1
        dns-nameservers 8.8.8.8
        post-up route del default gw 192.168.0.1 eth0
        post-up route add default gw 1.2.3.1 eth1

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.0.55
        netmask 255.255.255.0
        gateway 192.168.0.1

but when I reboot I have to manually delete the 192.168.0.1 eth0 gateway and add the 1.2.3.1 eth1 one. Why isn't this persisting across a reboot? Is there some other place where the default route/gw is set?

batflaps
  • 179
  • 1
  • 3
  • 10

2 Answers2

2

You have two different gateways configured for two interfaces, which is never going to work the way you want. If you need only one default gateway then configure also one. You don't need a gateway for the LAN (192.168.0.0/24) to communicate internally. If you have ip_forward enabled then the lan computers will be able to go to internet anyway.

Try this:

/etc/network/interfaces

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.0.55
        netmask 255.255.255.0

# The secondary network interface
allow-hotplug eth1
iface eth1 inet static
        address 1.2.3.4
        netmask 255.255.255.0
        gateway 1.2.3.1
        dns-nameservers 8.8.8.8
Diamond
  • 9,001
  • 3
  • 24
  • 38
0

I think, eth1 brings up before eth0 and script trying to delete a non-exist route.

Try this:

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth1
allow-hotplug eth1
iface eth1 inet static
        address 1.2.3.4
        netmask 255.255.255.0
        gateway 1.2.3.1
        dns-nameservers 8.8.8.8
        post-up ifup eth0
        post-up route del default gw 192.168.0.1 eth0
        post-up route add default gw 1.2.3.1 eth1

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.0.55
        netmask 255.255.255.0
        gateway 192.168.0.1
strangeman
  • 433
  • 5
  • 19