How to install a loopback interface in Linux for GNS3.

After successful installation of GNS3, we will install loopback adapter on our Ubuntu, Centos, Redhat and Fedora systems, so that we can telnet into your routers.

Loopback tap installation on Ubuntu
user@admin-desktop:~$ sudo –i
root@ admin-desktop:~#apt-get install uml-utilities
root@ admin-desktop:~#modprobe tun
root@ admin-desktop:~#tunctl             This will create loopback interface tap0
root@ admin-desktop:~#ifconfig tap0 10.100.100.100 netmask 255.255.255.0 up
root@ admin-desktop:~#ifconfig            verify that tap0 is up and given ip is assigned.


If you want to add one more loopback interface
root@ admin-desktop:~#tunctl             This will create loopback interface tap1
root@ admin-desktop:~#ifconfig tap1 10.100.101.100 netmask 255.255.255.0 up

********************************************************************************
 
Loopback tap installation on Centos/Redhat/Fedora
We need tunctl which is not available in our local repositories. So we’ll have to add RPMForge repository. Steps to add this repo is given here
http://wiki.centos.org/AdditionalResources/Repositories/RPMForge (Steps are the same for other 2 distros as well)

Ok lets install tunctl

[user@admin ~]$ su
Password: (Type in your root password here)
[root@admin /]# yum install tunctl
[root@admin /]# modprobe tun
[root@admin /]# cd /usr/sbin
[root@admin sbin]#./tunctl           This will create loopback interface tap0
[root@admin sbin]# /sbin/ifconfig tap0 10.100.100.100 netmask 255.255.255.0 up
[root@admin sbin]# /sbin/ ifconfig     verify that tap0 is up and given ip is assigned.

If you want to add one more loopback interface
[root@admin sbin]#./tunctl                 This will create loopback interface tap1
[root@admin sbin]# /sbin/ifconfig tap1 10.100.101.100 netmask 255.255.255.0 up

Change the ip with ifconfig according to your requirement.


Run GNS3 with root privileges, or you won’t be able to add these tap interfaces to GNS3.
Fire up GNS3


Drag the cloud onto the work-board and right click on it, Select Configure. Then Select NIO TAP, type tap0, press Add. Click Apply & ok. Now connect it to your router. 

 Important: Add these lines to iptables

sudo iptables -I INPUT -j ACCEPT -i tap0
sudo iptables -I OUTPUT -j ACCEPT -o tap0


Happy Learning :)