Debian Jessie /etc/network/interfaces post-up route gateway won't persist reboot

7,473

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
Share:
7,473

Related videos on Youtube

batflaps
Author by

batflaps

Updated on September 18, 2022

Comments

  • batflaps
    batflaps over 1 year

    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?

  • Diamond
    Diamond over 8 years
    Sorry, can you point pls where is the difference in config?
  • strangeman
    strangeman over 8 years
    @bangal post-up ifup eth0 Trying to up eth0 before deleting a route