How to configure GNS3 installed on Linux to support more than 8 NIC for Qemu Instances

Recently I have read a question on GNS3 forum asking whether Qemu supports more than 8 network adapters. According to Google search, maximum number of adapters for Qemu virtual machines can be configured with a parameter #define MAX_NICS 8 in a file ./include/net/net.h under Qemu source tree. After you set desirable value you must compile and install Qemu from source.

However I have noticed that changing the integer value in the line #define MAX_NICS  has no effect on the maximum number of NIC allowed for Qemu VMs. I notice that I can start Core Linux Qemu machine with 18 network adapters even Qemu 2.2.0 was compiled with parameter #define MAX_NICS set to 1.

Now we know that Qemu itself does not limit the maximum network adapters to 8. We will go ahead and investigate GNS3. Navigate to Edit -> Preferences -> QEMU VMs and click on existing Qemu VM. Click on Edit button for this VM and navigate to Network tab. Increase the number of Adapters to 9.

The GNS3 1.2.1 allows to add maximum 8 NICs for a particular Qemu virtual machine. To avoid this limitation we have edit GNS3 source files and recompile GNS3 GUI and server. Here are the the steps for Linux.

1. Download and extract GNS3 1.2.1 Linux Sources

$ wget http://54dbd800be60307ab3fb-af183b57d94afbc9487771ea4c2db268.r84.cf5.rackcdn.com/GNS3-1.2.1.source.zip
$ unzip GNS3-1.2.1.source.zip

2. Install GNS3 GUI

$ cd gns3-server-1.2.1
$ unzip gns3-gui-1.2.1.zip
$ cd gns3-gui-1.2.1/

Edit a file qemu_vm_configuration_page_ui.py a change an integer number in a line self.uiAdaptersSpinBox.setMaximum(8) to  value that represents the number of required network adapters.

$ vi gns3/modules/qemu/ui/qemu_vm_configuration_page_ui.py

self.uiAdaptersSpinBox.setMaximum(18)

Now GNs3 should allow to configure 18 NIC for each Qemu VM. But first we have to recompile GNS3 GUI.

$ sudo python3 setup.py install

Picture1_Qemu_Network_Tab

Picture 1 - GNS3 QEMU VM Network Adapters Configuration

3. Install GNS3 Server

$ cd ../
$ unzip gns3-server-1.2.1.zip
$ cd gns3-server-1.2.1/

Edit a file schemas.py and change a parameter "maximum": 8, in these three parts of the file:

$ vi gns3server/modules/qemu/schemas.py

"adapters": {
"description": "number of adapters",
"type": "integer",
"minimum": 0,
"maximum": 18,
},

"port": {
"description": "Port number",
"type": "integer",
"minimum": 0,
"maximum": 18
},

"port": {
"description": "Port number",
"type": "integer",
"minimum": 0,
"maximum": 18
},

Note: The number 18 in the line "maximum":18 should match the value that we configured in a file  qemu_vm_configuration_page_ui.py.

Now we can recompile GNS3 server with the command:

$ sudo python3 setup.py install

4. Test Connectivity Between Core Linux Qemu Instances

I have created a simple GNS3 topology that consists of two Linux Core hosts emulated by Qemu. Each Core host  is occupied with 18 Ethernet Interfaces (Eth0 - Eth17). Hosts are connected via their interface ETh17.

Picture2_Simple_Topology_for_Testing_Connection

Picture 2 - Topology for Testing Connectivity Between Linux Core Hosts

Core-I
tc@box:~$ sudo su
root@box:~# echo "ifconfig eth17 192.168.1.1 netmask 255.255.255.0" >> /opt/bootlocal.sh
root@box:~# /opt/bootlocal.sh
root@box:~# /usr/bin/filetool.sh -b

Core-II
tc@box:~$ sudo su
root@box:~# echo "ifconfig eth17 192.168.1.2 netmask 255.255.255.0" >> /opt/bootlocal.sh
root@box:~# /opt/bootlocal.sh
root@box:~# /usr/bin/filetool.sh -b

We should be able to ping Linux Core-II IP address 192.168.1.2 from the host Core-I.

Picture3_Testing_Connectivity_from_Core-I

Picture 3 - Testing Connectivity Between Linux Core Hosts

End.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.