How to route to a GNS3 host in a Live Raizo VM

In this blog, I’m going to cover how to route to a GNS3 host in a Live Raizo VM. To do this, we need to set up routing from the host machine, to the Live Raizo VM and on to the GNS3 host that resides within that environment. It needs a couple of routing hops but it will enable applications on the host machine to access things within the GNS3 environment and vice versa.

What that means is you could use a web browser installed on the host to access the https GUI on a virtual switch in GNS3. Conversely, you could access an authentication server on the host machine from a GNS3 client in the Virtual Machine.

In an earlier blog post, we covered how to create a Live Raizo VM that used the VM hard drive to save persistent files. You can view that post here.

The first thing required before any routing can take place is that the directly connected hosts can communicate with each other. In this case, it means the host machine can communicate with the Live Raizo VM, and the Live Raizo VM can communicate with the GNS3 environment.

Setting up the host interface to the virtual machine

1; We need to identify which network interfaces connect between the host machine and the virtual machine. Open a command window by clicking on the Windows Start button and typing “cmd” (without the quotes). You can either then press return or click on the cmd.exe icon to start the program.

2; In the command window type “ipconfig /all” and press the Enter key. The output will show details of all the network adapters on the computer, both virtual and physical. Since we are using VirtualBox as our virtualization platform, we can see that Connection 9: is the one we need because of the description ” VirtualBox Host-Only Ethernet Adapter”.

Note that without the “/all” completion in the command line, the description line isn’t shown in the output.

How to route to a GNS3 host in a Live Raizo VM. Finding the ethernet adapter of the VM in the CLI
Finding the VirtualBox Host-Only Ethernet Adapter in the CLI

3; We can use the above information to find the adapter in the Network section of the Windows Control Panel. Click on the Windows Start Button and type “network” and then click on “Network and Sharing Center”, then click “Change Adapter Settings”

How to route to a GNS3 host in a Live Raizo VM. Finding the ethernet adapter of the VM in the GUI
Finding the VirtualBox Host-Only Ethernet Adapter in the GUI

4; Right-click on the VirtualBox Adapter and choose “Properties”, then in the Networking tab, scroll down and select Internet Protocol Version 4 and again click “Properties”.

Selecting IP Version 4 from Local Area Connection Properties. Windows 7
Selecting IP Version 4 from Local Area Connection Properties

5; From the TCP/IPv4 Properties window, we can change the IP address and Default Gateway. We can use the existing address in this case, and since we don’t want to have the default route going to the Virtual Machine, we can leave the routing, until later.

How to route to a GNS3 host in a Live Raizo VM. Changing the IP address and default gateway of an adapter.
Changing the IP address and default gateway of an adapter.

Setting up the virtual machine interface to host

6; We also need to identify the interface on the VM that connects to the host so open VirtualBox and start the Live Raizo VM. Once the VM has started type in “ifconfig” and press enter to show the details of the adapters present.

From the VirtualBox Manager window, we can see that the host adapter is “Adapter 2” (1), and if we click on “Network” (2) the “Settings” window opens and we can click on the Adapter 2 tab to see the details. The MAC address that is shown at (3) matches the MAC address of the adapter enp0s8 (4) so we now know which adapter to configure our IP address on.

How to route to a GNS3 host in a Live Raizo VM. Finding the ethernet adapter of the Live Raizo machine.
FInding the ethernet adapter on the Live Raizo virtual machine

7; Type “sudo ifconfig enp0s8 192.168.56.10/24” (without quotes) to configure the IP address for the interface. Without going to too much detail about the above command, we are setting the IP address of the enp0s8 interface to be in the same range, and with the same netmask as the connected host interface. As they are in the same IPv4 network, they should be able to communicate without routing which we can test with the ping command.

Type “ping 192.168.56.2” to test. If the test is unsuccessful at this point, check the firewall of the host machine and make sure it allows ICMP echo from the local 192.168.56.0/24 subnet.

Configuring the host-only adapter of the VirtualBox Live Raizo VM
Configuring the host-only adapter of the VirtualBox Live Raizo VM

Setting up the GNS3 environment in Live Raizo

8; Type “startx” in the Live Raizo CLI and after the GUI has loaded, right-click and select “Simulators>GNS3”

Starting GNS3 in Live Raizo.
Starting GNS3 in Live Raizo.

9; Click on “OK” to start a project. You can change the name as desired.

10; From the GNS3 GUI, select the “Browse all devices” (1) from the browser bar on the left and then drag a “Cloud” (2) and a “VPCS” (3) device to the project window in the centre.

  • As David pointed out in the comments, there is a “Live Raizo” device that could be used instead of the cloud. The Live Raizo device already has the virbr0 interface attached so if you use it, you can jump to step 12 and connect PC1 to the virbr0 interface of the Live Raizo device.
Creating a project in Live Raizo GNS3 to test routing to the host machine
Creating a simple project to test routing in Live Raizo and GNS3

11; Right-click on the cloud and choose to configure it. Then check the box to “Show special Ethernet interfaces (1), and from the drop-down (2) select virbr0. Click “Add” (3) and then “OK” (4).

Configuring a cloud in GNS3 in a Live Raizo VM to allow routing to the host machine
Configuring a cloud in GNS3 in a Live Raizo VM to allow routing to the host machine

12; Now we can add a link between the two devices using e0 on the VPCS and virbr0 on the cloud. Click the “Add a link” icon (1) and then select PC1 e0 and Cloud1 virbr0 (2).

Adding a link between two devices in GNS3 in a Live Raizo VM
Adding a link between two devices in GNS3 in a Live Raizo VM

13; We now need to configure IP addresses on both PC1 and on Cloud 1. The Cloud 1 IP will be the gateway for PC1. Right-click PC1 and choose Start. Once it has started, right-click on PC1 again but this time choose “console”.

Once the console opens we can type “ip ?” (1) to see the help menu. Then type in “ip 192.168.57.10/24 192.168.57.1” (2) (you can choose your own IP for this). Then type “show” (3) to see the result.

Configuring a VPCS PC in GNS3 in a Live Raizo VM
Configuring a VPCS PC in GNS3 in a Live Raizo VM

Configuring the Live Raizo virbr0 interface for GNS3

14; Return to the Live Raizo terminal by right-clicking on the desktop and selecting “xterm” then type in “sudo ifconfig virbr0 192.168.57.1/24” and press “Enter”. This will configure the IP address of the interface of the Live Raizo VM connected to the GNS3 environment. Once this is done we should be able to ping the GNS3 VPCS PC1 IP address from the Live Raizo VM as we can see from the screenshot below.

  • Live Raizo has provided some useful shortcuts. As David has pointed out in the comments the Live Raizo command ” fast-nat -d -n 192.168.57.1″ applies the IP address to the virbr0 interface (with a 24-bit mask) and runs the command “sudo sysctl -w net.ipv4.ip_forward=1” to make the VM forward IPv4 packets, so using fast-nat cuts out step 17. The fast-nat command also configures the VM to NAT packets outbound on the enp0s8 interface which means the host machine doesn’t need to know the route back to the 57 network to return the traffic, however, the route is useful if you want traffic inbound from the host to the GNS3 devices.
  • If you need to preserve the GNS3 IP address, perhaps to use as an identifier to an authentication service running on the host machine, you might prefer not to use fast-nat. There’s no reason why you couldn’t create your own script to configure the interfaces as you’d like them though.
  • Finally, fast-nat configures DHCP for hosts on the virbr0 interface, and DNS by default. The two options above “-d” prevents DHCP and “-n” prevents DNS from being configured.
Configuring and testing the Live Raizo to GNS3 connection
Configuring and testing the Live Raizo to GNS3 connection

Pinging the Live Raizo VM virbr0 IP address from the host PC results in timeouts, so the host machine needs investigating

C:\Users\user>ping 192.168.57.1

Pinging 192.168.57.1 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 192.168.57.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Users\user>

15; Typing “route print” or “netstat -rn” will output the routing tables including the IPv4 route table as below.

Windows host output from Route Print
Windows host output from Route Print

Configuring the Host to route to the GNS3 network

16; From the above image we can see that the default route (0.0.0.0 0.0.0.0 to gateway 192.168.43.1) is not sending traffic to the Live Raizo VM, (and neither is anything else) so we need to add a specific route, which we can do in the command window by typing “route add 192.168.57.0 mask 255.255.255.0 192.168.56.10 -p”

The command returns the following if it was successful. Note that the “-p” at the end of the command means the route will remain in the routing table even after the computer is rebooted.

C:\Users\user>route add 192.168.57.0 mask 255.255.255.0 192.168.56.10 -p
OK!

At this point, however, we still can’t ping the 192.168.57.0/24 network, but the problem is with the Live Raizo VM.

Configuring the Live Raizo VM to forward packets

17; The final part of the process is to configure the Live Raizo VM to forward packets with the linux command “sysctl”. Going back to the teminal on the Live Raizo VM type in “sysctl -w net.ipv4.ip_forward=1” and press “Enter”.

18; Pinging the GNS3 VPCS PC1 from the host machine now produces the following result. Successful end to end pings.

C:\Users\graham>ping 192.168.57.10

Pinging 192.168.57.10 with 32 bytes of data:
Reply from 192.168.57.10: bytes=32 time=2998ms TTL=63
Reply from 192.168.57.10: bytes=32 time=2ms TTL=63
Reply from 192.168.57.10: bytes=32 time<1ms TTL=63
Reply from 192.168.57.10: bytes=32 time=1ms TTL=63

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

C:\Users\user>

To cut a long story short, the summary

This blog covered how to route to a GNS3 host in a Live Raizo VM from the host machine itself.

This required configuring the VirtualBox host-only interface and the VM host-only interface with IP addresses in the same subnet. Then going on to create a Cloud device in the GNS3 program and connecting that to a virtual interface on the Live Raizo VM. Configuring both the cloud device and a connected GNS3 virtual PC device in another subnet. Once the local connectivity was proven using ping tests from the Live Raizo VM to both the GNS3 PC and the to the host machine, we added routing information to the host laptop and configured the Live Raizo VM to forward packets. We could then ping from the host PC to the GNS3 virtual PC.

If you’re a network engineer and you could use an IPv4 subnet calculator check out the free techiedoodah IPv4 excel subnet calculator spreadsheet and if you get a lot of time hands on rackside and need a tray to put your laptop on, let us know what you think of the Portable Rack Mount Laptop Tray and sign up if you want one. Type with two hands instead of one, be more comfortable, improve your productivity and get out of the server room sooner, (or wherever the rack happens to be).

Techiedoodah blogs are created in the hope that they can help others by giving real-life examples. If this has been useful to you please feel free to leave a comment. If you’re reading this post on the home page, you won’t be able to post comments here, so follow this link to the blog, and then scroll to the comments section at the bottom of the page.

Comments for How to route to a GNS3 host in a Live Raizo VM.

2 thoughts on “How to route to a GNS3 host in a Live Raizo VM

  1. Hi

    Why don’t you use LiveRaizo’s additional features to speed up your configuration?
    – Device “LiveRaizo” instead of “Cloud”
    – “fast-nat -d -n 192.168.57.1” to do “ifconfig virbr0…” and sysctl

    1. Hi David
      Thanks for the suggestion. Yes using the device “Live Raizo” and “fast-nat” certainly speeds things up.
      It makes sense to use the “Live Raizo” device as it has the virbr0 interface already attached which cuts out the need to configure the cloud.
      Also, while it’s useful to know the linux commands to configure interfaces and forwarding, using fast-nat is easier.
      Kind Regards
      Graham

Leave a Reply

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