How to connect your GNS3 lab to your physical network
How to connect a virtual lab to a physical lab
Creating an isolated, virtual network topology in GNS3 is quite easy.
But what if you want to create a virtual network, including Cisco IOS routers, VMWare Windows/Linux clients and servers, and make them appear in your LAN, as if they were real physical machines?
My goal is to get as close as possible to reality. I want to be able to deploy a virtual lab for workmates and students in a classroom, and they should be able to ping/telnet/ssh/whatever into any virtual machine in the topology.
This tutorial was made for Linux desktops; If you need a Windows tutorial, head over here: http://www.smartpctricks.com/2014/06/connecting-gns3-real-networks.html
Host network config
I'm using GNS3 1.5.2, running under a Xubuntu host.
First of all, we have to disable NetworkManager, because we want to have full control over our network interfaces.
Then, we have to create a TAP interface, and bridge it to our physical interface. Why a TAP interface? It's a kind of logical interface that is able to receive raw ethernet frames. This will allow us to link our GNS3 virtual machines to a physical adapter.
Let's install the uml-utilities, used to install the TAP:
sudo apt-get install uml-utilities
Backup your interfaces files:
sudo cp /etc/network/interfaces /backup/interfaces.bak
Now, the funky part: Creating the TAP interface.
There are several ways to do this, you will find conflicting information about this on the web. Some people think you have to create the tap and run GNS3 as root.
I strongly disagree with their method. We can create the TAP interface and run GNS3 as a normal user.
In order to create a TAP for user user, use the following command:
sudo tunctl -t tap0 -u user
Other tutorials on the web will tell you to put an ip address on the TAP interface. We don't need to do that because the TAP will be bridged. Only the bridge should have an ip address.
Let's create a bridge between our newly created TAP interface and the physical one:
This is where it get a little bit tricky. I found some very conflicting information on the web, and even some very bad advice that broke my config (What's new?).
Edit the file /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto br0 iface br0 inet static bridge_ports enp5s0 tap0 address 192.168.1.250 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 184.108.40.206 bridge_stp off bridge_fd 0 bridge_maxwait 0
Notice that I didn't configure the TAP nor the physical interface in that file. The nice thing with the bridge interface command bridge_ports enp5s0 tap0 is that it will automatically bring these interfaces up, when you restart the networking service.
(Adjust with your interface names and ip configuration; turn STP/spanning tree on if needed)
Restart the Networking service with the following command:
systemctl restart networking
First, let's drag a Host object into the workspace. This object represents our host machine, including the virtual/physical interfaces.
Right click on that object, and click Configure. Add your TAP interface in the TAP tab if necessary:
Next, you should be able to connect your host to other devices, through a switch, like this: (Notice I connected my cable to the tap0 interface)
I can now ping from the Xubuntu host to the CentOS server: (N.B I set the R1 ip as my default gateway in my Xubuntu host)
But most importantly: Other physical devices on the network can see the virtual router interface; you can even set it as a default gateway and DHCP server for any real machine connecting to your LAN :)
Helpful link: https://help.ubuntu.com/community/KVM/Networking