How to connect GNS3 to the internet in MacOSX
Posted by Josh on Sat 27 Dec 2008Categories: Cisco , Cisco Routers , Dynamips , GNS3 , MAC - [14] Comments
Here at Blindhog.net, we have issued tutorials for connecting Windows or Linux to a physical network using gns3, but apparently, there is a little difference for MacOSX. I recently received an email from one of our readers, Ivan Pletenev. Ivan describes how to connect GNS3 to internet through wifi-interface in MacOSX. You will find his writeup below. Thanks Ivan!
To set up this connection we need to do 2 things:
- Connect MacOSX and GNS3 through loopback-interface
- Set up NAT in MacOSX
First of all, like blindhog.net says, we need to edit our GNS3 .net file. After that we will have something like this:
[localhost:3700]
workingdir = /Users/besch/tmp/gns3
[[3640]]
image = /Users/besch/Documents/Documentations/cisco/c3640-jk9o3s-mz.124-16a.bin
ram = 96
chassis = 3640
[[ROUTER R1]]
model = 3640
console = 2002
cnfg = /Users/besch/tmp/gns3/WLANRouter/R1.cfg
slot0 = NM-1FE-TX
f0/0 = nio_tap:/dev/tap0
[GNS3-DATA]
[[Cloud C0]]
connections = R1:f0/0:nio_tap:/dev/tap0
Now we need a loopback interface (tap0). Download and install tuntaposx program from http://tuntaposx.sourceforge.net/
After installing we can check that we have necessary devices by running ‘ls /dev’ command in the console window. If you have tap0..tap15 and tun0..tun15 in your listing, then everything is ok.
But we still don’t have the created tap interface. To create tap0 interface all we need is just open our GNS3-project. But it has to be opened with root privileges. Execute this command in the console:
sudo chown root:wheel /Applications/GNS3.app/Contents/Resources/dynamips-0.2.8-RC2-OSX-Leopard.intel.bin
Now we can open our project. Then we need to set up our new tap0 interface:
sudo ifconfig tap0 10.100.100.100 netmask 255.255.255.0
The last thing – setting up router’s interface in GNS3 and checking connection:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#ip address 10.100.100.101 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exit
R1(config)#do ping 10.100.100.100
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.100.100, timeout is 2 seconds:
.!!!!
2 . Now let’s try to connect our R1 with internet. I remind you that we have an wireless connection (interface en1, ip 10.189.249.130). All what we need to do is to use NAT:
Lets check do we have IP Forwarding turned on?
sysctl net.inet.ip.fw.forwarding
If we’ve got 1 – it’s on, if 0 – then we have to turn it on:
sudo sysctl -w net.inet.ip.forwarding=1
The same thing for the firewall:
sysctl net.inet.ip.fw.enable
if we’ve got 0 – we need to turn it on:
sudo sysctl -w net.inet.ip.fw.enable=1
Now let’s run natd and add rule for firewall:
sudo natd -alias_address 10.189.249.130 -interface en1 -use_sockets -same_ports -unregistered_only -dynamic -clamp_mss
sudo ipfw add divert natd ip from any to any via en1
The last thing – setting up router’s gateway of last resort in GNS3 and checking connection:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 0.0.0.0 0.0.0.0 10.100.100.100
R1(config)#do ping google.com
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 72.14.205.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 148/184/220 ms
December 27th, 2008 at 8:42 pm
nice post….
February 6th, 2009 at 4:31 am
Excellent tutorial. I’ve spend many hours trying to get GNS3 to talk to the internet but without success. Seems like the key is the IP forwarding and NAT.
Thanks.
March 3rd, 2009 at 10:19 pm
I had to also execute the following to get dynamips to run as root:
sudo chmod +s /Applications/GNS3.app/Contents/Resources/dynamips-0.2.8-RC2-OSX-Leopard.intel.bin
March 13th, 2009 at 7:44 pm
And backwards?
If i have the CUCM in my physical network i can’t reach the GNS network with this setup – right?
April 1st, 2009 at 8:13 pm
Hi Josh i am new to gns3, and I am looking for the linux Lab to this. please help
I run ubuntu
April 1st, 2009 at 9:11 pm
Hi Josh i am new to gns3, and I am looking for the linux Lab to do this. please help
I run ubuntu
April 22nd, 2009 at 5:44 pm
Hi I have a Macbook and when I tried to cread the tap0 using this command
sudo ifconfig tap0 10.100.100.100 netmask 255.255.255.0
but I get this message:
ifconfig: interface tap0 does not exist
can you help me please?
thank you
May 18th, 2009 at 7:10 pm
Cant seem to get this working.
What is supposed to happen after i enter the following command, it asks for password then nothing.
sudo chown root:wheel /Applications/GNS3.app/Contents/Resources/dynamips-0.2.8-RC2-OSX-Leopard.intel.bin
This command says ifconfig: interface tap0 does not exist
sudo ifconfig tap0 10.100.100.100 netmask 255.255.255.0
Thanks in advance.
May 27th, 2009 at 8:21 am
Giovanni, did you install tuntaposx?
Robert:
1. you need do sudo command to give the neccessary rights to dynamips-0.2.8-RC2-OSX-Leopard.intel.bin.
2. Again – did you install tuntaposx?
May 27th, 2009 at 8:22 am
Giovanni, did you install tuntaposx?
Robert:
1. you need to do sudo command to give the neccessary rights to dynamips-0.2.8-RC2-OSX-Leopard.intel.bin.
2. Again – did you install tuntaposx?
July 24th, 2009 at 2:46 pm
I am having the same issue. I did install tuntaposx and if I look in /dev i can see the tap0 – tapx files. I used the sudo command to give the necessary rights but I still get tap0 does not exist.
September 13th, 2009 at 11:07 pm
Hi all!
I need your help please:
I’m getting the following error: “ifconfig: interface tap0 does not exist”
Have you found how to fix this issue?
Thanks in advance
September 28th, 2009 at 1:27 pm
I am also having this issue. No “tun” entries are listed in /dev (I can only see tap0-15). I cannot bring up int tap0. Could this be related to the Cisco VPN client for Mac OS installed on my Mac?
October 4th, 2009 at 8:01 pm
Well, I have been trying to get the tap0 int to work for around 6 months now. I am not trying to get it to connect to the Internet, but to a 3560 switch so I can do some CCIE labs.
Until this post, it has never worked…I get the same results as everyone else, Giovanni, Robert, etc.
I made a .net file the same as above, then did ifconfig -l and did not see the tap0 int.
Then I started my .net file (not even using the sudo commands as above). After the gns3 .net file loaded – I saw a connection from C0 to R1 for the first time ever!!!
Then I did another ifconfig -l and there was the tap0 interface!!!
Hope this helps.
Marc