Sunday, September 18, 2011

Connecting Your PC to Your Virtual GNS3 Routers

Update: Please also see my "Virtual Equipment + Physical Equipment = Big Lab" post for more information.

As you already know, GNS3 allows you to create virtual routers on your PC. What some people struggle with is connecting their physical PC to their virtual GNS3 network. In this blog entry, I'll explain how this can be done using GNS3's cloud object.

Note: Before you make any changes to your PC's routing table (as per the instructions below), please make sure you know what your doing. Changing the routing table may cause you to lose network connectivity to parts of your network. If this happens to you, rebooting your PC should resolve the issue.

Note: Once the PC is connected to the virtual GNS3 network, it will act as if it were connected to a real network. For example, you will be able to use it has a DHCP server,Web server, Syslog server, packet sniffer, etc, as well as a normal networked PC.

Note: PC Firewall software as well as Malware Prevention software installed on your PC can prevent this process from working. If you find this guide does not work for you, please disable all Firewall and Malware Prevention software and try again. 

1) First, you'll need to install a loopback adapter on your PC.

2) Next, you'll need to fire up GNS3 as an Administrator. To do this, you have to right click on the GNS3 icon, and select "Run as Administrator".

Note: Using an Administrator account is not enough. You still need to follow the above instruction.

3) Once GNS3 has started, locate the "Cloud" node in the "Node Types" panel and drag it in to the workspace.

4) Double click on the "Cloud" node, then, when the new screen opens click on the "NIO Ethernet" tab. At the top of the screen you'll see the "Generic Ethernet NIO (Administrator access required)" dropdown menu.

Click on the dropdown and select the "MS Loopback Adapter" option, then click "OK".

5) Next, create your GNS3 topology the way you normally would. Give a thought to your IP address plan too.

Note: Make sure your IP address plan does not conflict with the network that your physical PC connects to. Failing to do so may prevent your setup from working.

6)  Connect the Cloud node to one of the routers in your topology the same way you connect other devices to one another.

Once you have done the above, your GNS3 topology should look like this:




7) As you can see from the example topology above, the physical's PC's address is going to 10.50.50.2. To configure this, in Windows, navigate to the "Manage Network Connections" settings and locate your "MS Loopback Adapter". Configure the adapter with the above mentioned IP address.

8) Your PC will now be connected to the virtual network. This can be confirmed by sending a couple of pings: 

ping 10.50.50.1

Pinging 10.50.50.1 with 32 bytes of data:
Reply from 10.50.50.1: bytes=32 time=63ms TTL=255
Reply from 10.50.50.1: bytes=32 time=62ms TTL=255
Reply from 10.50.50.1: bytes=32 time=32ms TTL=255
Reply from 10.50.50.1: bytes=32 time=50ms TTL=255

Ping statistics for 10.50.50.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 32ms, Maximum = 63ms, Average = 51ms


However, pings to all other virtual network subnets will not work at this stage. This is because your PC will be using the default route configured on your physical network card to try to access these networks. To fix this, continue on to Step 9.

9) What you'll need to do now is install a route on your PC, telling it to route traffic destined to virtual networks through your loopback adapter.

For this example you'd need to issue the following command: 

route add 172.16.15.0 mask 255.255.255.0 10.50.50.2 

Note: You will need to add a route for every subnet you are using in your virtual GNS3 network and point it out of your loopback interface.

Once you have done that, your data will be able to flow freely between the virtual network and your physical PC.

And that's it! Your done!

Here is an example of a Syslog server running on the physical PC. It is receiving log messages from both R1 and R2 (10.50.50.1 and 172.16.15.2 respectively):




Update: Please also see my "Virtual Equipment + Physical Equipment = Big Lab" post for more information.

UPDATE
Please see my new website for a step by step guide, including screenshots and network diagrams.

As always, if you have any questions or have a topic that you would like me to discuss, please feel free to post a comment at the bottom of this blog entry, e-mail at myciscolabsblog@gmail.com, or drop me a message on Twitter (@OzNetNerd).

Note: This website is my personal blog. The opinions expressed in this blog are my own and not those of my employer.

5 comments:

  1. Hi, It looks like lab is working fine. I have a question. How can I ping the same GNS3 based routers from other PCs on the same network of PC on which GNS3 is installed. for example suppose this lab is installed at PC1 and I want to ping these networks from other PCs like PC2 and PC3 etc. your help is required

    ReplyDelete
  2. Hi,

    Many thanks for your tutorial "Connecting Your PC to Your Virtual GNS3 Routers". I am thoroughly done from top to bottom accordingly to your instruction, but at the end I locked up with two things:

    First, how do I install the route route add 172.16.15.0 mask 255.255.255.0 10.50.50.2 telling it to route the traffic destined to my virtual networks through my loopback adapter. Is this done on gns3 router or on my pc. If it is on pc how do I do.

    Secondly, I don't have loopback interface on my gns3 cloud as I went to drop down list on configuration, there are only three interfaces: 1. Bluetooth, 2. local host (local area connection), 3. wireless. How do I install loopback int on the cloud.

    I would be very much grateful to you if you kindly tell me the tricks.



    Thanks.


    bhoj_ccnp


    ReplyDelete
    Replies
    1. "First, how do I install the route route add 172.16.15.0 mask 255.255.255.0 10.50.50.2 telling it to route the traffic destined to my virtual networks through my loopback adapter. Is this done on gns3 router or on my pc. If it is on pc how do I do."

      It is on your PC. Open up a command prompt and paste that command in. Please see my website for more detailed instructions as well as screenshots: http://www.ultimateciscolab.info/

      "Secondly, I don't have loopback interface on my gns3 cloud as I went to drop down list on configuration, there are only three interfaces"

      Try rebooting your PC and then looking again. If it is still not there, run the GNS3 as the Administrator, however that should not be necessary.

      Delete
  3. HI,
    I have created the MS loopback adaptor and am able to ping to my GNS networks.
    but i am unable to telnet to any of the networks. (using PUTTY). configurations for vty etc on the routers is all done. I am using a windows 7 PC. is there more to do to get telnet access.

    i am not trying console access. Trying to do telnet on port 23 to the GNS router. ping to the same ip works.

    ReplyDelete
  4. Bonjour (Hi),
    all of this works fine !
    So our PC is able to access any virtual machine (VM) in our GNS3 network.
    But i can't manage to have any VM access the external world, namely the internet !
    Would you kindly help me solve this issue ?
    Didier

    ReplyDelete