Virtual network devices
Tun/tap
Allocate a tun/tap device
Note that tun/tap device can only be enabled by attaching an application to it.
sudo ip tuntap add dev tun0 mode {tun|tap}Program interface
Create a new interface or to attach to a persistent interface.
Open /dev/net/tun file and obtain the file descriptor.
Issue an ioctl() system call and if it succeeds, the virtual interface is created and the file descriptor we had is now associated to it, and can be used to communicate.
Bridge
Allocate a bridge device
sudo ip link add name br0 type bridgeAttach a device to a bridge
Note that tun device cannot be bridged because it does not have MAC address.
sudo ip link set tap0 master br0References
Last updated
Was this helpful?