I have a script (bottom of question) which adds a dummy link, adds some addresses to that link, and adds some routes to that link.
How can I make ip link
, ip addr
, and ip route
commands persist?
I'm using Debian stretch, NetworkManager is installed.
Thought 1:
If I put this file in /etc/network/if-up.d/
it might be called when the machine boots. /etc/NetworkManager/dispatcher.d/01ifupdown
seems to point to this directory.
Update: I tried, it wasn't a good idea
Thought 2:
I might need to translate this into a different configuration language and put it in /etc/network/interfaces.d/
, but the examples I've seen so far for configuring this file assumes that devices exist. I haven't found a configuration line which is equivalent to ip link add mocknet type dummy
.
This file relies on the auto
keyword at the start of lines to identify physical interfaces (auto mocknet
), but mocknet
doesn't exist yet.
Working script
ip link add mocknet type dummy
ip addr add 10.10.1.1/24 dev mocknet
ip addr add 10.10.2.1/24 dev mocknet
ip addr add 10.10.3.1/24 dev mocknet
ip addr add 10.10.4.1/24 dev mocknet
ip addr add 10.10.5.1/24 dev mocknet
ip addr add 10.10.6.1/24 dev mocknet
ip addr add 10.10.7.1/24 dev mocknet
ip addr add 10.10.8.1/24 dev mocknet
ip addr add 10.10.9.1/24 dev mocknet
ip link set mocknet up
ip route del 10.10.1.0/24
ip route del 10.10.2.0/24
ip route del 10.10.3.0/24
ip route del 10.10.4.0/24
ip route del 10.10.5.0/24
ip route del 10.10.6.0/24
ip route del 10.10.7.0/24
ip route del 10.10.8.0/24
ip route del 10.10.9.0/24
ip route add 10.10.1.0/24 dev mocknet proto kernel scope link src 10.10.1.1 metric 6000
ip route add 10.10.2.0/24 dev mocknet proto kernel scope link src 10.10.2.1 metric 6000
ip route add 10.10.3.0/24 dev mocknet proto kernel scope link src 10.10.3.1 metric 6000
ip route add 10.10.4.0/24 dev mocknet proto kernel scope link src 10.10.4.1 metric 6000
ip route add 10.10.5.0/24 dev mocknet proto kernel scope link src 10.10.5.1 metric 6000
ip route add 10.10.6.0/24 dev mocknet proto kernel scope link src 10.10.6.1 metric 6000
ip route add 10.10.7.0/24 dev mocknet proto kernel scope link src 10.10.7.1 metric 6000
ip route add 10.10.8.0/24 dev mocknet proto kernel scope link src 10.10.8.1 metric 6000
ip route add 10.10.9.0/24 dev mocknet proto kernel scope link src 10.10.9.1 metric 6000
/etc/systemd/network/
configuration files./etc/systemd/network
?