How to create a persisted TAP interface with static IP address?

I’m using a TAP interface to connect to my virtual network inside GNS3, doing:

sudo ip tuntap add mode tap tap0
sudo ip addr add dev tap0
sudo ip link set dev tap0 up

But I noticed that, running ip addr show after a reboot, it was in DOWN state and missing that IP address that I added previously, meaning I had to manually bring it up and set the IP address again.

I researched around and found tutorials on Arch Linux wiki, but nothing about TAP interfaces (I don’t know whether they differ or not from the network bridges in the tutorials).

From: Network configuration - ArchWiki

iproute2 is a dependency of the base meta package and provides the ip(8) command-line interface, used to manage network interfaces, IP addresses and the routing table. Be aware that configuration made using ip will be lost after a reboot. For persistent configuration, you can automate ip commands using scripts and systemd units. Also note that ip commands can generally be abbreviated, for clarity they are however spelled out in this article.

1 Like

Oh, that figures haha. So, automating the commands is the only way around?

One way or another, yes. Use NetworkManager to set it up or whatever.

1 Like

Thanks, will check it out! I’ll come back with further updates.