Utility to bring interfaces up and shut them down.
ifup eno1
ifdown eno1
The ifup/ifdown utility keeps record of whether an interface is up or down. It is possible that a different utility will change the state of an interface causing it to conflict with what ifup/ifdown believes its state to be. Meaning, an interface is up while ifup/ifdown believes it's down and vice versa - this will cause ifup/ifdown to error when issuing up/down commands.
Check the contents of /run/network/ifstate
- ifup/ifdown uses this file to note which interfaces can be brought up and down. Use the --force
option to override what the ifstate
file says and force an interface into either state.
ifdown --force eno1
Now, eno1
has been forced to the down state (ifdown
believed (based on the ifstate
file) the interface to truely be down, but it was up) - the interface and file now align with what is true.
This can be accomplished a few different ways:
1. Modify the interfaces
file, add an up
or down
declaration to run the proceeding command.
auto ens192
allow-hotplug ens192
iface ens192 inet static
address 192.168.221.54/24
gateway 192.168.221.1
dns-nameservers 82.99.137.41 212.158.133.41
dns-search example.com
up ip route add 192.168.0.0/24 via 192.168.221.1 dev ens192
up ip route add 192.168.1.0/24 via 192.168.221.1 dev ens192
down ip route del 192.168.0.0/24 via 192.168.221.1 dev ens192
down ip route del 192.168.1.0/24 via 192.168.221.1 dev ens192
2. Create a bash script in /etc/network/if-up.d/
. Scripts in this directory will be run during an interface up event - same is true for if-down
events.
#!/bin/sh
if [ "$IFACE" = "eno1" ]; then
ip route add 10.0.0.0/8 via 172.16.17.1 dev eno1
ip route add 172.16.0.0/12 via 172.16.17.1 dev eno1
fi
auto dummy0
iface dummy0 inet manual
address 172.31.255.1/32
pre-up /sbin/ip link add dummy0 type dummy
pre-up /sbin/ip address add 172.31.255.1/32 dev dummy0