How to create a TUN/TAP device at startup using systemd toolset, on an Ubuntu server?

My need is:

Server starts -> Setup network as usual -> Create TUN/TAP device -> Start dnsmasq to manage DHCP for new-created TUN/TAP NIC -> Start some VPN server.

systemd-networkd service seems to be disabled by default on Ubuntu server 17.10. Will there be problem (conflict with other network management) if I enable it?

1 Answer 1


On 18.04 networkd seems enabled, and seems to exist with NetworkManager.

Here's how to get systemd to create a tap device. You create a netdev file and restart systemd-networkd.

# /etc/systemd/network/90-tap0.netdev


See systemd.netdev(5) for more info on the file format and the Tap/Tun section. The vhost-net is a group I am using to restrict access to that device. You may not need that.

When you edit the netdev file, restart networkd to apply the changes. You can also examine the tap0 device to see if it is set up the way you want:

# systemctl restart systemd-networkd
# ip link show dev tap0
# ip tuntap list
  • On Ubuntu 18.10, systemd-networkd is still disabled.
    – hongquan
    Oct 23, 2018 at 2:21

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.