How to create a new GNS3 appliance template to work with SONiC using a dedicated Linux script?

Are you excited about enhancing your GNS3 network testing capabilities with SONiC but concerned it might be too complex? No need to worry! :) 

GNS3 doesn't come pre-configured with SONiC, but we'll guide you through a straightforward method to set it up. This guide simplifies the process into easy-to-follow steps that anyone can follow. We'll provide you with all the necessary resources to take your network tests to the next level 😎. In this article, you'll learn how to create a new SONiC appliance for GNS3 using a shell script on Ubuntu and how to add a template in Web version of GNS3 and Desktop version of GNS3.

So, are you prepared to embark on this journey with us? We'll seamlessly integrate SONiC into your GNS3 environment – it's a breeze! 🚀😉 To add a device with SONiC you'll need a gns3a file, which is a pre-configured script with all information that GNS3 needs. Once you have saved SONiC image on your PC, we'll need to open Linux to create a new appliance for GNS3. You can use WSL2 on Windows with Ubuntu.

Keep in mind that there are various ways to add SONiC images to GNS3, and we're presenting one of them.

Prerequisites

  • A functional GNS3 Server -> Link to the article where it's all explained

  • Access to the requisite SONiC image.

  • A fundamental understanding of networking concepts and familiarity with GNS3 operations.

  • Ubuntu client

Generate a new SONiC appliance for GNS3 using Ubuntu

1. Open your Ubuntu, and after you logged and type in console:

git clone https://github.com/GNS3/gns3-registry.git

2. Type in console:

krzysztof@NB-TECH15:~$ cd gns3-registry
krzysztof@NB-TECH15:~/gns3-registry$ python3 new_appliance.py

proceed as shown below. As we are creating a new appliance for SONiC, we will use the name “SONIC-Community” in both “Appliance filename” and “Appliance name”. Next, you'll need to pick the category of the appliance, we need to pick router - type 1 and press Enter.

3. Proceed as shown below – it is not important how you fill these in, if you can skip then go ahead. If you can’t skip then do as I did on the screen below.

Configure as seen below:

Type of network adapter: e1000

Number of adapters: 10

Ram allocated to the appliance (MB): 4096

Number of Virtual CPU: 2

Disk interface for the installed hda_disk_image: virtio

4. Skip the next one, we need only hda_disk_image - we did that in the previous screen.

Configure as seen below:

Architecture emulated: x86_64

Type of console connection for the administration of the appliance: telnet

Configure as seen below:

KVM requirements - type 3 for disable

Action to execute on the VM is closed - type 1 for power off.

5. The script now gets to the images. To add an image, proceed to the next step:

Type to start adding the image.

Filename” is the name of the file that you typed in .img file, so for this example it's sonic-vs.img. “Version of the file” is the current version of the SONiC instance, so for this example it's Community.

6. We need the md5sum of the image file. To do that, you need to go to the location where the image is located. Type the command with path to the image. The example outcome is underlined in the screen below. Copy that outcome and paste it to the script.

We need the size of that file in bytes, to do that you can repeat what you did in the previous step with md5sum. To check the size of your image file, you'll need the ls -l command. The example outcome is underlined in the screen below. Copy that and paste it to the script.

The next optional steps can be skipped. The script will loop and you'll be asked again for to add the image. Type n for stop.

7. The script will ask you to “add appliance version”. Type y to start the script

The “appliance version name” is the current version of SONiC, so for this example it will just be SONiC-Community.

Select image only for hda_disk_image. Type 1 in the CLI.

The next optional fields can be skipped. Script will loop again, type n to stop.

Congratulations!

You created a appliance file that you need to configure a new device in GNS3! In the next step we'll use that.

 

Step 2. Adding new device with appliance.

1. Enter GNS3, select the File button in the top-left corner of the GNS3, and select the Import appliance button from the drop-down list. Select the .gns3a file that you created earlier.

4.png

5.png

2.Select Install the appliance on the main server button, and click Next

6.png

3. Change Qemu binary to:

/bin/qemu-system-x86_64

And select Next

7.png

4. In the next window you will see your .img image that is applied to your .gns3a file. Select Next.

8.png

5. In the final window there is information about the category. Select Finish and there will be a window about the successfully created appliance.

9.png

Congratulations!

You have successfully created a SONiC template in GNS3. Now you can utilize SONiC in your GNS3 network simulations.

Happy Networking !!! 😉

Adding new device with appliance using web version of GNS3.

So, we learned how to add a new appliance in the downloaded GNS3. In this step, you'll learn how to add a new appliance in the web version of GNS3. First, you need to enter the address of your web version of GNS3.

1. Enter an existing project, if you don't have any click Add blank project.

10.png

2. Select the + icon and from the drop-down table select the New Template option.

11.png

3. Select Import an appliance file and click Next

12.png

4. Select the .gns3a file that you created using the Linux shell and click the Open button.

13.png

5. Change Qemu binary to:

/bin/qemu-system-x86_64

And select Create

14.png

15.png

Congratulations!

You have successfully created a SONiC template in GNS3. Now you can utilize SONiC in your GNS3 network simulations.

Happy Networking !!! 😉

If you're looking for more GNS3 tutorials and resources, you can explore the following articles:

How to create a new GNS3 appliance template to work with SONiC using GNS3 Desktop Client?

How to set up GNS3 server on VirtualBox?

How to create a new GNS3 appliance template to work with SONiC using GNS3 Web UI?

How to create a new GNS3 appliance template to work with SONiC using Linux shell?

Was this article helpful?
0 out of 0 found this helpful

Articles in this section