Setting up a KVM virtual network with DHCP on host

dhcpkvm-virtualizationvlan

I'm doing a voluntary network workshop on basic networking in a Linux environment. The idea is to show them how networking works, and give possible solution for migrations to Open source solutions instead of current pure Microsoft ones.

I have a limited on using a live USB, or in the worst scenario a live DVD. I was planning on having Lubuntu with KVM preinstalled and have 2 small Debian installations as virtual machines.

The idea was to try to set a DHCP server on the Lubuntu host, and have it assign the IP-s for the virtual client machines.

Then try to separate the clients, so that each is on a separate LAN, and set the host as router with NAT, so that the clients can access the Internet through the host, and ping each other even though they are on different subnets.

Then we'd also like to setup a DNS on the host, so the subnets can have each a domain name…

Which virtual networking option would you suggest?

I don't want the bridged option in which the hosts will get their IP from the real router cause then we cant experiment with router setup on the host computer.

However, if we use the KVM NAT, then we again can't setup the router on the host.

I guess what we're looking for is how to achieve just a "virtual physical" 🙂 network connection, and leave all the other handling to the host.

Best Answer

You create two bridges:

  • BR1: Shared by your host machine that does the DHCP (eth0)
  • BR2: Shared between your host machine that does DHCP (virtual eth1) and on your virtual machines

You can then do NAT for your WAN IP towards the virtual machines and configure DHCP.