Ubuntu 18.04: How to create a persistent dummy network interface

I am trying to create a dummy network interface on a Ubuntu 18.04 server. Here is how I would do it on my previous Ubuntu 16.04 servers:

In /etc/network/interfaces.d/dummy.cfg, write: auto dummy0 iface dummy0 inet static address 192.168.98.1 netmask 255.255.255.0 And then add source /etc/network/interfaces.d/dummy.cfg in /etc/network/interfaces/

From what I understand, Ubuntu 18.04 does not use /etc/network/interfaces anymore, we should use netplan instead. Apparently netplan does not support the creation of virtual interface (!) https://bugs.launchpad.net/ubuntu/+source/nplan/+bug/1743200.

I can create the dummy interface with the iproute2 toolkit instead: $ ip link add dummy0 type dummy $ ip addr add 192.168.98.1/24 dev dummy0 $ ip link set dummy0 up But this interface will disappear after reboot, as one would expect.

How can I create such a dummy network interface that will persist after reboot?


I had the same problem on 18.04 server and directly used the systemd-networkd way of configuring interfaces:

I created 2 files in /etc/systemd/network/:

  1. 10-dummy0.netdev

    [NetDev]
    Name=dummy0
    Kind=dummy
    
  2. 20-dummy0.network

    [Match]
    Name=dummy0
    
    [Network]
    Address=192.168....
    Address=fe80::.....
    

On boot the dummy interface is created automatically with IPv4 and IPv6 addresses an is shown in ip addr . Also systemctl restart systemd-networkd should create the interface.

I filed a bug on netplan, please support: https://bugs.launchpad.net/netplan/+bug/1774203

The docs:

https://www.freedesktop.org/software/systemd/man/systemd.netdev.html# https://www.freedesktop.org/software/systemd/man/systemd.link.html# https://www.freedesktop.org/software/systemd/man/systemd.network.html#