1

I have two interfaces on a Debian Stretch install where I want to change the default gateway after booting the box to the second interface. I have a working config from Jessie that I updated to reflect Stretch like:

# The primary network interface
allow-hotplug ens3
iface ens3 inet static
    address 1.2.3.4/24
    gateway 1.2.3.1
    dns-nameservers 8.8.8.8

allow-hotplug ens9
iface ens9 inet static
    address 5.6.7.8
    netmask 255.255.255.0
    gateway 5.6.7.1
    post-up ip route change default via 5.6.7.1
    #post-up route del default gw 1.2.3.1 ens3
    #post-up route add default gw 5.6.7.1 ens9

The post-up route commands don't appear to work on Strech (but did on Jessie), and the post-up ip route change command doesn't work either, though if I run it later from command line like:

ip route change default via 5.6.7.1

It works fine. What am I doing wrong? I guess I could put it in a cron job to run 30 seconds after start, but why won't it work in my /etc/network/interfaces config file?

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.