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.
- 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
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.
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.
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
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 menu1.
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 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.
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.
This screen capture also shows that the GNS3 user interface can be modified by removing panels, or adding panels, as required ↩