GNS3 can be used to simulate a network composed exclusively of open-source routers, switches, servers, and hosts.
In this post, we will investigate how well GNS3 works when we use it strictly as an open-source network simulator, without using Cisco or Juniper routers in the simulation.
Build the network in GNS3
We are using VirtualBox to run the Linux virtual machines in our simulated network. When using VirtualBox, we must prepare a VirtualBox virtual machine for each node we will use.
Let’s use the virtual machines we already prepared in the the previous post about setting up GNS3 with virtual Linux routers. In this case, we will have five virtual machines prepared: three hosts and two routers.
After starting GNS3, add three hosts, two routers, one switch, and some ethernet links to create the topology shown below.
To build the topology, click on the Browse all Devices button to show the Devices panel. Use the following devices to create the nodes.
- router-virtualbox
- This is the custom node we created in an earlier post. Use this for the routers Quagga-1 and Quagga-2.
- VirtualBox Guest
- Use this for the host computers Host-1, Host-2, and Host-3.
- Ethernet Switch
- This is a basic switch provided by GNS3. Use it to creat the switch SW1.
Add network devices
First, click on the router-virtualbox device and drag it to the middle panel in the GNS3 window. After you drop it, a dialogue box appears asking which VirtualBox guest will run on this node. Choose the guest, Quagga1, which has a disk image with Tiny Core Linux, Quagga, and Openvswitch installed.
Now a router symbol with the label Quagga1 appears in GNS3.
Repeat this process for each device in the planned topology until we have three hosts, two routers, and one switch arranged as shown below.
Add network links
Click on the Add a Link button to set up links between the nodes in the network. The button will change to show a red stop sign with a white “X”. This indicates we need to click the button again to exit the link-add mode when we are done adding links. GNS3 only supports Ethernet links between VirtualBox virtual machines so we do not need to select the link type. The default link type, GigaEthernet, will work correctly.
To add a link between two nodes, click on the first node, then select the port in the pop-up menu. Then click on the second link and select the port. The link is created. In this case, we will connect the two routers so that the link connects port eth7 on each router. If you are wondering which ports are already used, you can check in the Topology Summary panel in the lower right of the GNS3 window. In the Topology Summary panel, double-click on the node you are interested in to see which ports are already connected.
Now create the network topology shown in the screen capture below. Connect port eth0 on each device to the appropriate network element: Quagga-1, Host-1, and Host-2 all connect to switch SW1; Quagga-2 connects directly to Host-3.
Start the network simulation
Now that we have created the devices and links, we can start the routers and hosts in the network and configure them so we can perform some very basic tests on the networking software on each device.
Click the Start All Devices green arrow button on the GNS3 user interface. All the links will in network diagram turn green. All the nodes listed in the Topology Summary panel will turn green.
Login to all devices
Now, we log into each node using its console window.
You can start a console on any individual node by right-clicking on the node and selecting Console from the drop-down menu; or by clicking on a node and then clicking on the Console button at the top of the GNS3 user interface (it looks like a small terminal screen).
You can start all consoles at the same time by clicking on the Console connect to all devices command in the GNS3 Control menu.
Control → Console connect to all devices
A new terminal window will appear for each virtual machine. Arrange the terminals on your desktop according to your preference. Hit the Enter key on each terminal to get a prompt.
The login for each virtual machine we are using in this example is tc
.
box login: tc
Now we are logged into each of the hosts and routers in the network.
Configure the network devices
We can configure each node in the network so that the routers can route traffic from one network to the other and then we will run a few basic tests to verify that the configuration works.
We will configure three networks and set up a dynamic routing protocol, OSPF, that will run on the network connecting the two routers together and pass network information from one router to the next.
Network 10.0.100.0/24
The first network consists of the hosts Host-1 and Host-2 and the router Quagga-1. We will assign this network the network address, 10.0.100.0/24.
On Quagga-1, enter the following commands to start Quagga and use the Quagga command-line-interface to configure the router’s port eth0 with a valid IP address.
$ sudo vtysh
box# configure terminal
box(config)# interface eth0
box(config-if)# ip address 10.0.100.1/24
box(config-if)# exit
box(config)# exit
box#
On Host-1, enter the following commands to configure the eth0 interface on Host-1 and create a default route toward router Quagga-1 (which in this network has IP adress 10.0.100.1).
$ sudo ip addr add 10.0.100.2/24 broadcast 10.0.100.255 dev eth0
$ sudo ip route add default via 10.0.100.1
On Host-2, enter the following commands to configure the eth0 interface IP address and create a default route.
$ sudo ip addr add 10.0.100.3/24 broadcast 10.0.100.255 dev eth0
$ sudo ip route add default via 10.0.100.1
Now, each node on this network should be reachable by any other node on the same network. Host-1, Host-2, and Quagga-1 can all ping each other.
Network 10.0.200.0/24
The second network consists of the hosts Host-3 and the router Quagga-2. We will assign this network the network address, 10.0.200.0/24.
On Quagga-2, enter the following commands to start Quagga and use the Quagga command-line-interface to configure the router’s port eth0 with a valid IP address.
$ sudo vtysh
box# configure terminal
box(config)# interface eth0
box(config-if)# ip address 10.0.200.1/24
box(config-if)# exit
box(config)# exit
box#
On Host-3, enter the following commands to configure the eth0 interface on Host-3 and create a default route toward router Quagga-2 (which in this network has IP adress 10.0.200.1).
$ sudo ip addr add 10.0.200.2/24 broadcast 10.0.200.255 dev eth0
$ sudo ip route add default via 10.0.200.1
Network 10.0.1.0/24
The second network consists of the routers Quagga-1 and Quagga-2. We used port eth7 on each router to create the link between them. We will give this network the network address 10.0.1.0/24.
We are already running vtysh on both routers.
On Quagga-1, enter the following commands to configure port eth7, set up OSPF in the network, and to export directly connected network addresses to the OSPF protocol so they can be shared with other routers.
box# configure terminal
box(config)# router ospf
box(config-router)# network 10.0.1.0/24 area 0
box(config-router)# redistribute connected
box(config-router)# exit
box(config)# interface eth7
box(config-if)# ip address 10.0.1.1/24
box(config-if)# exit
box(config)# exit
box#
On Quagga-2, enter the following commands to configure port eth7, set up OSPF in the network, and to export directly connected network addresses to the OSPF protocol so they can be shared with other routers.
box# configure terminal
box(config)# router ospf
box(config-router)# network 10.0.1.0/24 area 0
box(config-router)# redistribute connected
box(config-router)# exit
box(config)# interface eth7
box(config-if)# ip address 10.0.1.2/24
box(config-if)# exit
box(config)# exit
box#
Network configuration completed
Now we are able to pass data from any node on network 10.0.100.0/24 to any node network 10.0.200.0/24. We can verify this by using the ping command to verify that data can pass from Host-1 on network 10.0.100.0/24 to Host-3 on network 10.0.200.0/24.
On Host-1, execute the ping command and see the following results:
$ ping -c 1 10.0.200.2
PING 10.0.200.2 (10.0.200.2): 56 data bytes
64 bytes from 10.0.200.2: seq=0 ttl=62 time=0.000 ms
--- 10.0.200.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.000/0.000/0.000 ms
We see that traffic will pass in both directions between Host-1 and Host-3 through all three networks in this simulation.
Capture and analyze network traffic
We can set up GNS3 to capture data on any interface in the network. To start a data capture, right-click on a link in the network diagram and then select Start capturing from the drop-down menu ((This screen capture also shows that the GNS3 user interface can be modified by removing panels, or adding panels, as required)).
Then select which interface on the link you wish to from which you want to capture data. Note that you cannot choose an interface connected to switch SW1; only interfaces connected to running virtual machines can support capturing data.
Restart node to enable data capture
We see an error message pop up that says we must restart the node that has the interface from which you want to capture data before data can be captured. This is an inconvenient feature in GNS3.
To restart the node, right-click on the node Quagga-1 and select Stop in the pop-up menu. At this point we will also add a second data capture point so that we are capturing data on both interfaces on router Quagga-1, eth0 and eth7.
To start the router Quagga-1 again, right-click Quagga-1 and select Start in the pop-up menu. When the node completes starting up, start the console and reconfigure the node as previously described.
Note: When we restart Quagga-1 we lose the configurations we made because the TinyCore Linux appliances provided by the GNS3 project are read-only filesystems. This is related to the Persistence feature of TinyCore Linux that we will discuss, along with a remedy, in a future post. In this case, we will need to enter in all our configurations again for router Quagga-1.
We now know that we should define any data capture points before starting the simulation and configuring the network nodes.
Start Wireshark
Start Wireshark to see the packets at each capture point. To view the data being captured, click on the interface in the Captures panel and then right-click to see the pop-up window. Select Start Wireshark from the menu.
A Wireshark window will open up showing the data that is being captured on that interface. In this case, we are looking at the data captured on the eth7 interface on router Quagga-1. We see OSPF packets being exchanged between Quagga-1 and Quagga-2.
Save the project
The project topology can be saved for future use. Use the following menu command or press the Ctrl-S key combination to save the project.
File → Save Project
Not all information related to the project is saved by GNS3. The data capture points are not saved. When you open the saved project, you must define your data capture points again.
Also, the node configurations are not saved and each node will need to be manually configured again when the saved project is started again. This is because we are using the read-only TinyCore Linux appliances provided by GNS3. In a future post, we will describe a procedure that creates persistent network configurations and saves them on each TinyCore Linux appliance.
Conclusion
We showed how to set up a network in GNS3 using only the open-source appliances provided by the GNS3 project. We demonstrated that the simulated open-source hosts and routers can be configured to pass data between themselves and to route packets from one network to another.
The GNS3 project provides Linux appliances that can be used as Linux switches, routers, and hosts. This makes it easier to use open-source software in GNS3 because the provided appliances are already configured to work correctly with GNS3.
When it is used exclusively to simulate open-source routers and hosts, GNS3 is provides similar functionality to, but is more complex to use, than other open-source network simulators. I understand that I have explored only a small portion of GNS3’s capabilities. GNS3’s main function is to emulate Cisco routers and using only open-source routers is not the normal GNS3 use-case.
Pingback: Persistent configuration changes in TinyCore Linux | Open-Source Routing and Network Simulation
Hi,
A very good article and rare article on how to use open source router and switches in GNS3.
I am a L2 & L3 developer. I have one doubt,
1. Can I integrate any router or switches with GNS3, or only that router and switches are integrable which is mentioned at GNS3 Website ?
2. I am using a executable of router and switches which is run on fedora 11, and this contains only control plane developement . There is no data plane. Can we integrate this router with GNS3.
3. After clicking on start or run button , what will happen in GNS3, executables are executed in background.
Please suggest me with a solution. I am a novice user to GNS3, so please sorry for a silly question.
Best Regards,
Abhishek
Hi Abhishek,
Thanks for your questions. Here is my best effort to answer them, in order:
1. You can incorporate any system that can run in VirtualBox into a GNS3 simulation. The GNS3 project team helpfully provides some prepared virtual systems but you can create your own. If you are just starting, and assuming you want to run open-source routers in GNS3, I suggest you use the Linux virtual systems provided by GNS3.
2. I am not sure what you mean when you say there is no data plane. The standard packet forwarding functions provided by the Linux kernel offer a suitable data plane for network simulation in GNS3. You can also manipulate forwarding performance using netem and traffic control.
3. When you start a GNS3 simulation, the virtual machines that are included in the simulation scenario start up. Some may start up faster than others but eventually they should all start.
Thanks,
Brian
Hi, really helpful write up on how to implement open source routing. I am a student and I’m currently doing a research on something similar. I have followed the instructions but get an error message that says “end of file on pipe magic during open” whenever I start wireshark. Any help please. Thanks in advance.
Best regards.
Does this help?
http://forum.gns3.net/topic6549.html
Hi, just letting you guys know about imunes. It’s very awesome if you’re doing opensource routing testing:
http://imunes.tel.fer.hr/
Yasser, I agree. I wrote about IMUNES in this blog, as well. Please see my posts about IMUNES.
Hi Brian, I’m trying to run some performance tests on quagga say bandwidth, throughput. Any idea on how I could go about this?
Kind regards.
Hi Abiola,
Are you testing the quagga control plan or the Linux kernel forwarding plane? Since you use terms like bandwidth and throughput, I think you are trying to measure packet forwarding performance, which is done by the Linux kernel in most cases. In that case, you want to generate packets at various rates, sizes, and patterns. iperf is an open-source tool that will do this.
If you want to test quagga performance, then you would want to test how fast a network of quagga routers can converge when the network topology changes, for the different routing protocols quagga supports. If you want to test a small- to medium-sized network, you could set this up in your virtual lab running on a PC. If you want to test quagga performance limits, may would need to create a large network (an emulated network spanning multiple physical servers) with many network addresses, or connect quagga to some test software that can emulate a large routing domain by generating routing protocol messages towards quagga.
Unfortunately, I don’t know about any free open-source software that can generate routing updates at various speeds towards a unit under test. You could create something using the NS-2 or NS-3 simulators, but you would have to do the programming yourself. If you have access to a commercial tester like IXIA, you could do this using their built-in tests.
I hope this helps.
Brian
Thanks for the quick reply Brian. I’m trying to measure packet forwarding performance and I have already set up a network and downloaded jperf the graphical version of iperf. My confusion is I get a network unreachable output whenever I put the ip address of any device on my gns3 network Although when I use the loopback address I get a result. Can you explain what is happening here pls. I think it’s because the gns3 devices on my network are virtual devices but I still don’t have a full understanding.
Thank you.
It looks like you have a routing issue. I suggest you check your quagga configuration. I understand you can ping the loopback interface of the first router. Can you ping the interface on the other side of the same router?
So sorry didn’t make myself understandable in the last message. I’m able to ping every device on the network. I was talking about the sending tcp packets on jperf. It only worked when used the loopback with as the server address , it didn’t when I used the given ip address of the devices on my gns3 network. I don’t quite understand how it works. Any help please? So sorry for bothering you.
Hi Abiola,
I would have to set that up myself to try to understand what is happening but unfortunately I am working on other projects right now. Maybe the issue is caused by jperf? To verify if the problem is related to TCP, try another program that generates TCP packets, such as tcptraceroute. Sorry I cannot help more.
Brian
Thanks a lot Brian. You’ve been really helpful.
Kind regards.
Pingback: GNS3 Version 1.3: What’s new for Open-Source Routers | Open-Source Routing and Network Simulation
Just implemented this on Linux Mint 17.3 and GNS3 1.3.6
Having a heck of a time just getting “ping” to work. It appears – looking at “ifconfig” packet count that the wrong Ethernet port is being selected by default (eth4 – but not all the time) – on both Quagga-1 and Quagga-2.
Any thoughts???
Hi Brian- for some reason i am unable to start all the devices. each of the routers and hosts node stays in red . It says the machine is stopped.I cant even get to open the console of any linux devices.
what am i missing – Really appreciated your help.
In other words if you are the topology summary all nodes continue to be Red except ethernet switch
please can I simulate a new protocol in GNS3?
please can I simulate a new protocol in GNS3? Meaning i want to simulate DDoS attacks, which i intend to use a new protocol to simulate. please is it possible its urgent please
You can run any software or protocol supported by the virtual machines you run in GNS3. If you protocol will run, for example, on Linux then you can use GNS3 to test it.