TUN/TAP, Name Spaces and Veth Notes

TUN interfaces are IP point-to-point style interfaces, TAP are Ethernet broadcast domains:

sudo apt-get install uml-utilities

# Add tap0
sudo tunctl

# Add with specific name
# sudo tunctl -t mytapname

sudo ip link set up dev tap0

# Delete tap0
sudo tunctl -d tap0


# Or by using the "ip" suite....
sudo ip tuntap add name tap0 mode tap
sudo ip link set up dev tap0

Veth pairs and LINUX network name spaces:

# Show network name spaces
sudo ip netns list

sudo ip netns add myprivatespace

sudo ip link add veth0 type veth peer name veth1
# This ^ should add veth0 and veth1, check with...
sudo ip link list

# Move veth1 into the private name space
sudo ip link set veth1 netns myprivatespace

sudo ip link set up dev veth0

# Veth1 is now missing from the output of "sudo ip link list".
# To view/edit it, the "ip" commands must be run inside of the
# "myprivatespace" name space...
sudo ip netns exec myprivatespace ip link list
sudo ip netns exec myprivatespace ip link set up dev veth1

# Run a program in a namespace
sudo ip netns exec myprivatespace /path/to/bin -some -args