There is an unbelievable amount of junk on the net that can send one in all the wrong directions. When it comes to dynamips it is no different and it seems everyone has a different opinion on what works and what does not. It probably depends on the OS dynamips runs on and the alignment of the moon and the stars. For me the best solution thus far was to run Dynamips on Ubuntu Linux server edition. The reasons for this is due to the 100Mb memory Ubuntu server consumes to run the OS as well as the stability and responsiveness of Dynamips on linux. It has worked well.
To break out to real switches I started with the multiple USB adapter approach. Basically you map each USB to Ethernet adapter to a router ethernet port in the dynagen net file. Sounds simple, and while it is, the USB approach for me turned out to be unreliable. It would work, then it would not. This plus the hassle with using USB adapters from different vendors and drivers just becomes messy.
After more research I tried the “switch in the middle” method. This is by far the easiest, quickest, cleanest and most reliable route:
Overview:
So you are probably already using dynamips to run the routers. To break out the first thing is to create a trunk between your linux server and a breakout switch. Then create a bunch of vlans on the linux server. One for every port that will connect to real switches e.g. if R2 needs to connect to the real switches with Fa0/0 and Fa0/1, create two vlans for this router. In the dynagen net file map each ethernet port to the vlan ’sub interfaces’ which were created when the vlans were created. Create the same vlans on the breakout switch that were created on the server. Assign each access port that will link to the real switches into a different vlan. Each access port on the breakout switch now represents a router port e.g. fa0/6 in vlan 106 on the breakout switch represents router R6 fa0/0 interface which connects to Sw2 fa0/6.
Requirements:
1) A second network card
2) The vconfig utility.
apt-get install vlan
3) Kernel that will support Dot1q
modprobe 8021q
4) A breakout switch. Try to stick with a Cisco switch.
5) If you want to support QinQ / dot1q-tunnel, the breakout switch needs to support QinQ tunneling
Steps:
1) Create a trunk between your linux server and another switch that will become the switch in the middle or breakout switch.
2) Create the required vlans on the server. Or use the following script to do steps 1 and 2.
#!/bin/bash
#############
# vlansetup.sh
# http://21500.net
################# Enable Dot1q support
modprobe 8021q#### Set the ethernet MTU
ifconfig eth1 mtu 1536#### Create the Vlans
vconfig add eth1 101
vconfig add eth1 102
vconfig add eth1 103
vconfig add eth1 104
vconfig add eth1 105
vconfig add eth1 106
vconfig add eth1 107
vconfig add eth1 108
vconfig add eth1 109
vconfig add eth1 110
vconfig add eth1 111
vconfig add eth1 112
vconfig add eth1 113
vconfig add eth1 114
vconfig add eth1 115
vconfig add eth1 116
vconfig add eth1 117
vconfig add eth1 118
vconfig add eth1 119
vconfig add eth1 120
vconfig add eth1 121
vconfig add eth1 122
vconfig add eth1 123#### Bounce the interface
ifconfig eth1 down
ifconfig eth1 up
3) Configure the trunk on the breakout switch
interface fastethernet 0/24
switchport trunk encapsulation dot1q
switchport mode trunk
4) Assign the Access ports their vlans
!
interface fastethernet 0/1
switchport access vlan 101
switchport mode access
!
interface fastethernet 0/2
switchport access vlan 102
switchport mode access
!
interface fastethernet 0/3
switchport access vlan 103
switchport mode access
!
interface fastethernet 0/4
switchport access vlan 104
switchport mode access
! …
! …
! …
interface fastethernet 0/23
switchport access vlan 123
switchport mode access
!
5) If you want to support QinQ and CDP between the virtual routers and the real switchs, your breakout switch needs to support QinQ. Enable a dot1q tunnel on each interface.
interface range fastethernet 0/1 – 23
switchport mode dot1q-tunnel
l2protocol-tunnel cdp
6) Map the ports in the dynagen .net file
[[ROUTER R1]]
f0/0 = NIO_linux_eth:eth1.101
f0/1 = NIO_linux_eth:eth1.103
[[ROUTER R2]]
f1/0 = NIO_linux_eth:eth1.102
7) Connect the switches to the breakout switch with crossover cables. In this example Port fa0/1 on the breakout switch represents Fa0/0 on R1 and connects to Sw1 Fa0/1.
R1 Fa0/0 -> BSw Fa0/1 -> SW1 Fa0/1
R2 Fa1/0 -> BSw Fa0/2 -> SW1 Fa0/2
R1 Fa0/1 -> BSw Fa0/3 -> SW2 Fa0/1
Once I got this working I found that someone already did the hard work. Wish I saw this much earlier. The only difference between the two methods is that I used one breakout switch while MrPaul’s method uses the Dynamips switches and the breakout switch.
HOWTO Connect Real Switches Using One NIC & QinQ
This is the image MrPaul made:

Hi, I have implemented yours and MrPaul setup, I can ping from virtualrouters to realswitches, but I have an issue, the cdps from virtual routers dont reach the real switches, they get via the trunk only to the BOsw, but not passed to the qinq interfaces, any idea?? thanks for your time
Comment by gedeon — May 26, 2009 @ 5:55 am
l2pt is only supported on dot1q-tunnel and PAgP interfaces, not on “normal” trunks.
Comment by Greg — June 3, 2009 @ 5:06 pm
Hi Gedeon, you need to enable:
l2protocol-tunnel cdp
Comment by 21500 — June 3, 2009 @ 8:48 pm
Greg, not sure whether I follow you there, but if I understand correctly you mean it is best to have a breakout switch that supports dot1q tunnels. Agree 100%
Comment by 21500 — June 3, 2009 @ 8:51 pm
Thank you for it. But I want to ask you something.
1.) Second ethernet card is a mandatory ? I can use one ethernet card where in my Notebook ?
2.) When We can connect to a router and L3 switch’s router port ( no switchport is entered in a interface of L3 Switch) , this system ;Qinq works correctly through tunneling ? (in other ways i.e experts RS labs Routed between a router and Port of switch: ip routing)
if you clear my doubt I am very grateful.
Comment by ret2ww — June 11, 2009 @ 9:04 pm
1) yes, one is enough. In your case you use the notebook so you dont need a management ip. There is another way to work around one ethernet card, is to assign one of the vlan ’subinterface’ with an ip address. Plug the workstation you will work from into the breakout switch on the port that maps to that ’subinterface’ on the dynamips server. This will allow you to communicate with the dynamips server through the breakout switch from your workstation.
2)Umm, if I follow you correctly, yes, even if your breakout switch does not support qinq, you can still use the ‘no switchport’ on the real switches, but qinq and trunking to virtual routers wont work. To make full use of the real switches I would suggest using a breakout switch that does support qinq. This will allow you to trunk to a virtual router e,g fa0/0.6 encap dot1q 6 and QinQ between virtual routers.
Comment by 21500 — June 12, 2009 @ 2:42 pm
THANK YOU for your answer.
1.) you say that if I have a ethernet card on my pc, I will do a config like the below on my ubuntu ? this process is assign one of the vlan ’subinterface’ with an ip address ?
vconfig add eth0 101
vconfig add eth0 102
vconfig add eth0 103
vconfig add eth0 104
vconfig add eth0 105
if ı am wrong could you give us an example of this?
2.) actually I didn’t talk about break out switch’s qinq support. we think that. Our switches support qing and L3 functions. In our topologies, one router through switch connection is L3, not trunk
ı posted a picture about my question
according to a part of topology in the picturei it is work without problem in our ubuntu dynamips with real switch and virtual routers ?
http://img193.imageshack.us/i/routerandswitch.jpg/
Comment by ret2ww — June 14, 2009 @ 10:41 am
1) Yes that config will work. Since you use one PC as both your workstation and to run the dynamips server, you will ‘console’ to the virtual routers via the dynamips/dynagen console, you dont need an ip address on the subinterface. You only need the ip address on one subinterface if you use a dedicated dynamips server with one network card and a different pc as a workstation. Somehow you need to connect to the virtual routers right? The only issue here is how will you manage the real switches? Via console cable?
2) Yes it will work, whether the breakout switch supports qinq or not.
Comment by 21500 — June 14, 2009 @ 11:07 am
Hi thank you again
Yes I manage the switches with console cable because my equipments is only on my job station and I don’t pay more money for them so I setup my topologies in my job place with my notebook and my companies switches in my spare time. I am working as the shift
after the right configuration on my topologies,Can I connect with telnet or ssh my switches over the virtual routers without problem?
thank you for interesting.
Comment by ret2ww — June 14, 2009 @ 9:58 pm
Does cdp work both ways with this setup?
Comment by buddy — July 15, 2009 @ 4:01 am
Hey, nice writeup and thanks for the mention.
You have any clever solutions to doing 5 ATM OC3 ports on a 7200 for the IP Expert Vol 2 Section 4 lab? I need this particular setup for the Cell Mode MPLS.
Comment by MrPaul — July 21, 2009 @ 12:23 am