I am looking for a clean, "modern" way to configure, start, and stop the dummy0
network interface (from the dummy
kernel module).
My /etc/network/interfaces
used to work on an older system but now fails silently on ifup dummy0
:
iface dummy0 inet static
address 10.10.0.1
netmask 255.255.255.0
# post-up ip link set dummy0 multicast on
Uncommenting the post-up
line produces this error (showing that it runs but that the interface is never created): dummy0: post-up cmd 'ip link set dummy0 multicast on'failed: returned 1 (Cannot find device "dummy0")
This shell script works perfectly but isn't a nice clean config file:
#!/bin/sh
sudo ip link add dummy0 type dummy
sudo ip link set dummy0 multicast on
sudo ip addr add 10.10.0.1/24 dev dummy0
sudo ip link set dummy0 up
My intention is to use it both manually and with a systemd service:
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ifup dummy0
ExecStop=/sbin/ifdown dummy0
StandardOutput=syslog+console
Environment:
- Kubuntu 18.04.2 LTS
- NetworkManager 1.10.6
- iproute2 4.15.0
- ifupdown2 1.0
- systemd 237 +PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid
Questions:
- How can I convert the shell script into a working
/etc/network/interfaces
configuration? - Are there any another cleaner or recommended ways to do this?
Best Answer
The interface wasn't "created" previously; ifupdown relied on it magically appearing as soon as the 'dummy' kernel module was loaded. This is old compatibility behavior, and (AFAIIRC) it also interfered with explicit creation of the same interface name, so it was disabled through a module parameter. Now dummy0 has to be created the same way dummy1 or dummyfoobar are created.
You should be able to create the interface in a "pre-up" command:
If you also use NetworkManager on this system, recent NM versions support dummy interfaces.
If the interface should be created on boot and remain forever, that can be done using systemd-networkd (one .netdev configuration to create the device, one .network config to set up IP addresses). However, 'networkctl' still does not have manual "up" or "down" subcommands.