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:


  1. Connect MacOSX and GNS3 through loopback-interface
  2. 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



Be Sociable, Share!