5 Command equivalence
This section spells out the physical equivalence to the commands that are used along with VMs and VDE.
- sudo tunctl -u user -t tap0
This step is similar to adding a new NIC to the host OS. The NIC has a symbolic name of tap0, this is how
we can identify this network interface later on. This step can only be performed with root privileges.
- vde_switch -s /tmp/switch --tap tap0
There are two steps in this step. The first step is powering up a network switch. The second step is to “plug
in” the host OS TAP device to one of the ports of the switch.
- slirpvde -s /tmp/switch --dhcp
This step starts up a gateway machine and connect it to the virtual switch. The gateway includes a DHCP
server, a DNS server and a NAT router.
- kvm ... -net nic,vlan=0 -net vde,sock=/tmp/socket,macaddr=...
This step powers up a virtual machine and connect its NIC to a port of the switch. It is up to the VM to run
a DHCP client to acquire an IP address from the DHCP server. A default Debian installation acquires an IP
address via DHCP. You may need to write down the IP address of each machine.
- sudo dhclient tap0
This final step runs a DHCP client on the host OS to acquire a TCP/IP address for the TAP interface. Without
this step, the host OS cannot communicate with the VMs connected to the virtual switch. You don’t need to
remember this IP address unless you want to access the host OS from the VMs. This step should be followed
by sudo route del default gw 10.0.2.2 so that the host OS does not use the VDE virtual gateway (or else
we can end up with a routing loop).