2

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:

  1. How can I convert the shell script into a working /etc/network/interfaces configuration?
  2. Are there any another cleaner or recommended ways to do this?
  • @sourcejedi Thanks, I'll update my post! – Oleg Apr 20 '19 at 21:18
4

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:

iface dummy0 inet static
    address 10.10.0.1/24
    pre-up ip link add dummy0 type dummy

If you also use NetworkManager on this system, recent NM versions support dummy interfaces.

nmcli con add type dummy ifname dummy0 ipv4.addresses 10.10.0.1/24 [...]

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.

| improve this answer | |
-1

Recently I needed bring two dummy interfaces on Oracle Linux 8 (standard 4.18 kernel). Automatic cleaning config files don't critical for me and I used Oleg's idea and theirs script on first post this thread and script for NetworkManager from the article Dummy interface on RHEL and wrote two simple scripts for bring up with startup two dummy interfaces

  • Load dummy module
    # echo "dummy" > /etc/modules-load.d/dummy.conf
    
  • Determinate two dummy interfaces
    # echo "options dummy numdummies=2" > /etc/modprobe.d/dummy.conf
    

Created two script - for example 98-dummy0 and example 99-dummy1- in /etc/NetworkManager/dispatcher.d/ directory:

98-dummy0

#!/bin/sh
# See the "DISPATCHER SCRIPTS" section of `man NetworkManager`.
# Remember to make this file executable!
# Create the dummy interface.
/sbin/ip link add dummy0 type dummy
/sbin/ip link set dummy0 multicast on
/sbin/ip addr add 10.10.0.1/24 dev dummy0 
/sbin/ip link set dummy0 up

For 99-dummy1 change IP adress to 10.10.0.2/24 and rename to dummy1.

Reboot and check

[mvg@oracle ~]$ ifconfig
dummy0: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.10.0.1  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::e4b7:27ff:fe33:73e9  prefixlen 64  scopeid 0x20<link>
        ether e6:b7:27:33:73:e9  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 10858 (10.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

dummy1: flags=4291<UP,BROADCAST,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.10.0.2  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::7c8a:e7ff:feee:b648  prefixlen 64  scopeid 0x20<link>
        ether 7e:8a:e7:ee:b6:48  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 78  bytes 10306 (10.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.131  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fdb0:34c:6e16:0:a01e:6127:6aa7:1bba  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::2cd7:76d7:c757:6b30  prefixlen 64  scopeid 0x20<link>
        ether 94:de:80:07:50:d2  txqueuelen 1000  (Ethernet)
        RX packets 15759  bytes 14474446 (13.8 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11577  bytes 1411688 (1.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 112  bytes 9480 (9.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 112  bytes 9480 (9.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:6b:09:b3  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Either dummy interface pinged.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.