Configure a Vbox network for GNS3 with Internet through a cloud with a TAP interface

Today we going to configure a virtual network within GNS3. We can download older GNS3 versiones from sourceforge or the most recent from  gns3.com.
We need to add the repositories to apt and after install gns3:

sudo add-apt-repository ppa:gns3/ppa
sudo apt-get update
sudo apt-get install gns3-gui

To have a connection to access Internet through our physical interface, we create a TAP interface (virtual bridge):

sudo apt-get install uml-utilities
modprobe tun
tunctl
ifconfig tap0 10.0.0.1 netmask 255.255.255.0 up

On the last line, you configure the ip, that will be the gateway for your virtual topology.
Now, as we need forward the packets, between the virtual network and your physical router, you must enable the forwarding option:

sudo iptables -I INPUT -j ACCEPT -i tap0
sudo iptables -I OUTPUT -j ACCEPT -o tap0
sudo sysctl -w net.ipv4.ip_forward=1

Now, you need an appliance or a any host image to create our virtual network. You can use a minimal Ubuntu version  downloadable from:

wget http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-i386/current/images/netboot/mini.iso

NOTE: You can use axel to download faster

After you create your VirtualMachine with VirtualBox, you need run it with GNS3 and configure.
If you need change your language keyboard, you may use this command, where 'es' is the language ID:

loadkeys es

If you need change your repositories zone, you can do that with this (in this case to Chilean repositories):

sed 's/us.archive.ubuntu.com/mirror.uchile.cl/g' /etc/apt/sources.list 

For connectivity, we need configure the gateway and the DNS inside the machines. For the gateway you can add this command as follows, where the ip 10.0.0.1 is the same that TAP interface:

sudo route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.0.0.1 dev eth0

Don't forget configure the eth0 ip with an ip in the same network:

sudo ifconfig eth0 10.0.0.10 netmask 255.255.255.0

To configure the DNS, you need edit /etc/resolvconf/resolv.conf.d/base file and add your favorite DNS servers:

nameserver 8.8.8.8
nameserver 8.8.4.4

After that, restart your resolv configuration with this command:

sudo resolvconf -u

Now, repeat the same for any amount of hosts and put them behind a switch (you need a switch to connect to tap iface). Connect a cloud to the switch and in the cloud option choice a TAP interface, where you need put the name of your TAP interface (by default is tap0).
Enjoy!






Comments

Popular posts from this blog

Exception: Could not find a default OpenFlow controller in Mininet

How to fix Android when developer options are not available for this user

Webcam streaming throught VLC with YUY2 compatibility