CCNA – Dynagen/Dynamips, Windows 7, Network Access

Having trouble with Dynagen on Windows 7 and getting external network access to your routers? Read on for information on how we solved the problem.

Spoiler Alert: PEBKAC

After doing literally days of research into the error I discuss below…well, yes, I found the problem, and it was Me. I ridiculously misinterpreted a Dynamips error message about an attempt to connect to non-existent interface as a problem with Dyanips integration with Windows 7 virtual network adapters. That was not the case. However, as so often occurs in our profession, the simple act of tirelessly pursuing an error – even a non-existent one – is instructive and leads to more knowledge. So carry on with me, Gentle Reader, as we together explore the mysteries of Dynamips, Dynagen, ProcMon, and the Windows Registry entries on virtual adapters. An educational and fun time will be had by all.

Dynagen/Dynamips and Network Access

Dynagen is a command wrapper over Connecting GNS3 to Real Networks. This article relates to GNS3 but remember that GNS3 is a GUI wrapper over Dynagen and Dynamips.

  • Connecting Dynamips Routers to Physical Switches, Located in Different Cities!. This article describes the detailed steps for connecting your virtual routers to a truly external network topology.
  • Part 1 of Dynamips External Cloud Interface on Linux. Another article that describes how to connect your virtual routers to an external network.
  • The actual process for creating an external connection is straightforward:

    1. Define a network adapter on your local machine. For Windows, you can create either a loopback interface as described in How to make GNS3/Dynamips communicate with your local network or you could use a tool like VMware Workstation to create a virtual network adapter.
    2. Start the Dynamips server on your local machine.
    3. Create your .NET configuration file with a router and a network module.
    4. Within the .NET configuration file, bind the virtual adapter (Microsoft loopback or VMware Workstation adapter) to a port on the network module.

    Once the router port is bound, you can then configure the router to get an IP address on that adapter and you have your external network access.

    Problems with Windows 7 and Binding to Virtual Network Adapters

    There are some known issues with Windows 7 and GNS3 – by extension, these are problems with Dynagen and Dynamips. According to the Free CCNA Workbook, “running GNS3 on other operating systems such as Windows Vista or Windows 7 is possible but due to the compatibility of GNS3, it is currently recommended that you run GNS3 on a Windows XP machine”. And despite numerous specific Windows 7 tutorials such as Connecting GNS3 lab to the internet – Lesson1, in our case we simply could not get connectivity to work. Specifically, we ran into the dreaded attempt to connect to non-existent interface when we tried to execute our .NET file.

    As it turns out, this was not really a problem (see the Spoiler Alert at the top). But why waste a perfectly good opportunity to do some debugging? Let’s get started!

    Our Lab Setup

    For this test to bind to Windows 7 virtual adapter, we use the following simple setup:

    # Win7-VirtAdapter.net
    autostart = False
    
    [localhost:7200]
        workingdir = C:\foo\Dynamips
    
        # setup for a simple legacy 3640 router
        [[3640]]
            chassis = 3640
            image = C:\foo\Dynamips\c3640-ik9o3s-mz.124-25b.image
            ram = 128
            ghostios = True
            sparsemem = True
    
        # load up R1 entry
        [[ROUTER R1]]
            model = 3640
            console = 41081
            slot0 = NM-1FE-TX
            f0/1 = NIO_gen_eth:\Device\NPF_{3BF34483-23DF-4017-8074-54241CA2F0AF}
    

    There are plenty of entries on how to read this file: Create a folder named C:\foo\Dynamips; Copy a Cisco IOS image file to it; Read up on the Dynagen documentation; and, then learn how to start Dynamips and Dynagen (hint: use Run as Administrator).

    So we have the above file, and two Administrator Mode command prompts opened up. We’ll use one to run Dynamips server and the other to run Dynagen. We won’t even bother with the old double-click on the file from Windows Explorer and we certainly won’t resort to a cop-out like GNS3 – after all, we love the command line 🙂

    Here’s the output from our run:

    Window 1 – the Dynamips Server

    C:\>"C:\Program Files (x86)\Dynamips\dynamips-start.cmd"
    Cisco Router Simulation Platform (version 0.2.8-RC2-x86)
    Copyright (c) 2005-2007 Christophe Fillot.
    Build date: Nov  9 2007 09:54:39
    
    ILT: loaded table "mips64j" from cache.
    ILT: loaded table "mips64e" from cache.
    ILT: loaded table "ppc32j" from cache.
    ILT: loaded table "ppc32e" from cache.
    Hypervisor TCP control server started (port 7200).

    All looks good on that end, the Dynamips emulator is started and ready for work. Now let’s run Dynagen manually:

    Window 2 – the Dynagen Process

    C:\>"C:\Program Files (x86)\Dynamips\dynagen.exe" C:\foo\Dynamips\Win7-VirtAdapter.net
    Reading configuration file...
    
    *** Warning:  Connecting R1 f0/1 to NIO_gen_eth:\Device\NPF_{3BF34483-23DF-4017-8074-54241CA2F0AF} resulted in
    :
            attempt to connect to non-existent interface in slot 0 on device R1
    
    *** Error:  errors during loading of the topology file, please correct them

    Ack. That’s not good, especially since we believed (wrongly, of course) that we had followed all instructions carefully. Our mis-reading of the above error message convinced us that the “non-existent interface” was the Windows 7 device listed above.

    What is this Windows 7 Virtual Network Adapter Anyways??

    In the above we see a reference to the following:
    f0/1 = NIO_gen_eth:\Device\NPF_{3BF34483-23DF-4017-8074-54241CA2F0AF}

    On the left is the interface on the emulated Dynamips router (hint – the error is staring us right in the face) and on the right is the stylized “WinPcap-ed” version of the Windows virtual network adapter. But that does beg the question – what is that virtual adapter and why are we using it and what did we think the problem was?

    Simply put – Run the Dynamips server with the -e option to show the list of installed virtual network adapters. Here’s the output:

    C:>"C:\Program Files (x86)\Dynamips\dynamips.exe" -e
    Cisco Router Simulation Platform (version 0.2.8-RC2-x86)
    Copyright (c) 2005-2007 Christophe Fillot.
    Build date: Nov  9 2007 09:54:39
    
    Network device list:
    
       rpcap://\Device\NPF_{3BF34483-23DF-4017-8074-54241CA2F0AF} : Network adapter 'VMware Virtual Ethernet Adapter' on local host
       rpcap://\Device\NPF_{3C2C3A7B-FD7A-4153-9172-07555A309FE5} : Network adapter 'Intel(R) 82579LM Gigabit Network Connection' on local host
       rpcap://\Device\NPF_{5E2E04F1-C1A0-48F9-B35A-38E097441E66} : Network adapter 'VMware Virtual Ethernet Adapter' on local host
       rpcap://\Device\NPF_{9579D7BB-3CB7-4F91-959A-B188BD86FFA0} : Network adapter 'MS LoopBack Driver' on localhost
       rpcap://\Device\NPF_{034085DF-3A99-4D0D-ABCE-ED36529F6068} : Network adapter 'Microsoft' on local host

    We have five network adapters listed. Because we’re running VMware Workstation you see a couple entries created by the VMware virtual network control panel. You also see that we installed the Microsoft Loopback Adapter. And – duh! – you can can see the local 1GbE NIC connection from the local PC we’re running our lab on.

    The way that Dynamips network binding works is that you attach a network adapter to an emulated switch or router. At that point it is exactly the same as if you had a real NIC, a real switch or router, and you were running a real RJ45 cable from that NIC to a port on the switch or router. Once you have that virtual connection created, you program the interface port on the switch or router just as if it was a physical entity. Tres Kewl.

    In the list above the possible choices for me to use are either of the two VMware Virtual Ethernet Adapters, or the Microsoft Loopback Adapter. Either could be used to NAT a connection to the outside world, or for strictly internal connections between processes running on the local PC and the emulated switch or router. Normally we’d use the VMware Virtual Ethernet Adapter so we can spin up Virtual Machines and easily connect them to our test routing infrastructure. However, on this particular PC we don’t actually have Workstation installed (the list above came from a different PC); so, we shall use the loopback adapter and solve our problem. From our troubleshooting view, it’s irrelevant which network adapter we use.

    The final bit of useful information we’ll take with us is the ipconfig /all results for the loopback adapter; here they are:

    Ethernet adapter Local Area Connection 3:
    
       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : Microsoft Loopback Adapter
       Physical Address. . . . . . . . . : 02-00-4C-4F-4F-50
       DHCP Enabled. . . . . . . . . . . : Yes
       Autoconfiguration Enabled . . . . : Yes
       Link-local IPv6 Address . . . . . : fe80::8d08:4b31:be43:3b65%18(Preferred)
       Autoconfiguration IPv4 Address. . : 169.254.59.101(Preferred)
       Subnet Mask . . . . . . . . . . . : 255.255.0.0
       Default Gateway . . . . . . . . . :
       DHCPv6 IAID . . . . . . . . . . . : 570556492
       DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-16-2B-D1-94-00-26-6C-CC-40-EA
       DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                           fec0:0:0:ffff::2%1
                                           fec0:0:0:ffff::3%1
       NetBIOS over Tcpip. . . . . . . . : Enabled

    All this is pretty standard…we have the loopback adapter, it has a MAC address, it has an APIPA address because we don’t have a DHCP server locally installed, and it’s ready to be used within our Dynamips environment.

    Let the Debugging Begin…

    At this point we have Dynamips/Dynagen installed, we have a .NET file created, and we have an error where we can’t bind to our selected virtual network adapter. Let’s follow this problem through as it is a great way to learn about Dynamips.

    The WinPcap’ed Adapter Name and the Windows Registry

    We’ll start with the results of dynamips.exe -e – the list of virtual network adapters. Dynamips actually uses the WinPcap package to integrate with network adapters on the local machine. WinPcap, on the other hand, references network adapters via entries in the Windows Registry. So let’s take a sample output from dynamips.exe -e on the PC we’re writing on right now:

    rpcap://\Device\NPF_{19C675BD-53DD-4F74-818B-D6902358DEE2} : Network adapter 'MS LoopBack Driver' on localhost

    If we open the Registry Editor (regedit from an Administrator command prompt) then we can do a search for the loopback adapter ID {19C675BD-53DD-4F74-818B-D6902358DEE2} from above. It’s quite instructive! You will find the adapter ID all over the place within the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control registry hive. Take a look at the following screenshot:
    ccna-dynamips-010

    So what this shows us is that the dynamips.exe -e output appears correct…the adapter ID {19C675BD-53DD-4F74-818B-D6902358DEE2} does match to the “Local Area Connection 3” Ethernet adapter from ipconfig /all above. So it appears that WinPcap works just fine and that Dynamips is integrating with the WinPcap library just fine – at least to find the adapter. Let the journey continue!

    Use the Source, Luke

    If WinPcap is working OK and Dynamips is getting info from WinPcap OK, then perhaps the problem is one relating to 64-bit vice 32-bit. Remember the warning above that GNS3 integrated “best” with Windows XP? That usually is code indicating that software which used to work great in a 32-bit world no longer works with 64-bit operating systems. So – since Dynamips and Dynagen are opensource – let’s take a look at the source code and see if we can find anything odd.

    • Dynamips Source Code – This is a C application that interfaces with the underlying OS to access network functions.
    • Dynagen Source Code – This is a Python application that wraps over Dynamips to permit multiple emulated switches / routers to be managed easily.

    Setup the Loopback Adapter

    Let’s start by setting an IP address on our loopback adapter. From an Administrator command prompt, use the netsh command on the loopback network adapter from the ipconfig /all command above:

    netsh int ip set addr "Local Area Connection 3" static 10.0.0.1 255.255.255.0 none

    Now rerun the ipconfig /all command:

    Ethernet adapter Local Area Connection 3:
    
       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : Microsoft Loopback Adapter
       Physical Address. . . . . . . . . : 02-00-4C-4F-4F-50
       DHCP Enabled. . . . . . . . . . . : No
       Autoconfiguration Enabled . . . . : Yes
       Link-local IPv6 Address . . . . . : fe80::b166:5f74:7afe:1b1f%27(Preferred)
       IPv4 Address. . . . . . . . . . . : 10.0.0.1(Preferred)
       Subnet Mask . . . . . . . . . . . : 255.255.255.0
       Default Gateway . . . . . . . . . :
       DHCPv6 IAID . . . . . . . . . . . : 822214732
       DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-19-CE-3F-F1-2C-59-E5-00-7E-FA
       DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                           fec0:0:0:ffff::2%1
                                           fec0:0:0:ffff::3%1
       NetBIOS over Tcpip. . . . . . . . : Enabled

    Yup, we've got the IP address. So let's continue.

    What about Just Dynamips?

    Given the error message above, let's try the command without Dynagen and instead just use base Dynamips. Dynamips can be invoked directly using options as specified in the README file included with the Dynamips download source from above. Let's try starting Dynamips to run a single emulated router session using one of our downloaded images and binding a network interface to the loopback adapter:

    C:>"C:\Program Files (x86)\Dynamips\dynamips.exe" -P 3600 -t 3640 -p 0:NM-4E -s 0:0:gen_eth:"\Device\NPF_{9579D7BB-3CB7-4F91-959A-B188BD86FFA0}" "C:\foo\Dynamips\c3640-ik9o3s-mz.124-25b.image"

    We won't cover every Dynamips command line parameter except for the ones we use:

    • -P 3600 - Emulate a platform, in this case the 3600-series of routers. Dynamips supports a number of router/switch series: 7200, 3600, 2691, 3725, and 3745. The one you use depends on the image you have available. We have the 3640 router image (version 12.4, release 25(b)).
    • -t 3640 - Emulate a specific chassis type, in this case the Cisco 3640 router.
    • -p 0:NM-4E - Define a network module, in this case a 4-port 802.3 Ethernet running at 10Mb, half-duplex. Dynamips supports up the following network modules:
      • NM-1E - Ethernet (10Mb, half-duplex), 1 port.
      • NM-4E - Ethernet (10Mb, half-duplex), 4 ports. This is what we are using for our debug test.
      • NM-1FE-TX - FastEthernet (100Mb, full-dupex, 1 port.
      • NM-4T - Serial, 4 ports. Normally serial connections are used only for router-to-router connections.
      • NM-16ESW - Ethernet (10Mb, half-duplex) switch module, 16 ports.
      • Leopard-2FE - Cisco 3660 FastEthernet in slot 0, automatically used.
    • -s 0:0:gen_eth:"device_name" - Bind a network IO interface to a network module; in this case we are binding the loopback adapter to the single Ethernet interface we defined above.

    Here's what we get:

    Cisco Router Simulation Platform (version 0.2.8-RC2-x86)
    Copyright (c) 2005-2007 Christophe Fillot.
    Build date: Nov  9 2007 09:54:39
    
    IOS image file: c:\foo\Dynamips\c3640-ik9o3s-mz.124-25b.image
    
    ILT: loaded table "mips64j" from cache.
    ILT: loaded table "mips64e" from cache.
    ILT: loaded table "ppc32j" from cache.
    ILT: loaded table "ppc32e" from cache.
    CPU0: carved JIT exec zone of 16 Mb into 512 pages of 32 Kb.
    C3600 instance 'default' (id 0):
      VM Status  : 0
      RAM size   : 128 Mb
      NVRAM size : 128 Kb
      Chassis    : 3640
      IOS image  : c:\foo\Dynamips\c3640-ik9o3s-mz.124-25b.image
    
    Loading ELF file 'c:\foo\Dynamips\c3640-ik9o3s-mz.124-25b.image'...
    
    [...output cut...]
    
    Cisco 3640 (R4700) processor (revision 0xFF) with 124928K/6144K bytes of memory.
    Processor board ID 00000000
    R4700 CPU at 100MHz, Implementation 33, Rev 1.2
    4 Ethernet interfaces
    DRAM configuration is 64 bits wide with parity enabled.
    125K bytes of NVRAM.
    8192K bytes of processor board System flash (Read/Write)
    
    
             --- System Configuration Dialog ---
    
    Would you like to enter the initial configuration dialog? [yes/no]:

    Look at that - no error reported and we are running just as if we booted a fresh start on a 3640 router! Moreover, we can check out our interfaces:

    Router>en
    Router#sh run | section include Ethernet
    interface Ethernet0/0
     no ip address
     shutdown
     half-duplex
    Router#

    Let's now assign an IP address and see if all works:

    We won't

    Use the Source, Luke

    If WinPcap is working OK and Dynamips is getting info from WinPcap OK, then perhaps the problem is one relating to 64-bit vice 32-bit. Remember the warning above that GNS3 integrated "best" with Windows XP? That usually is code indicating that software which used to work great in a 32-bit world no longer works with 64-bit operating systems. So - since Dynamips and Dynagen are opensource - let's take a look at the source code and see if we can find anything odd.

    • Dynamips Source Code - This is a C application that interfaces with the underlying OS to access network functions.
    • Dynagen Source Code - This is a Python application that wraps over Dynamips to permit multiple emulated switches / routers to be managed easily.

    Team-oriented systems mentor with deep knowledge of numerous software methodologies, technologies, languages, and operating systems. Excited about turning emerging technology into working production-ready systems. Focused on moving software teams to a higher level of world-class application development. Specialties:Software analysis and development...Product management through the entire lifecycle...Discrete product integration specialist!

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *