Generate Cisco IOURC license on GNS3 VM using Python 3

I was trying to add IOU L2 Switch image on GNS3 VM but an wired license error didn’t permit me to start the L2 Switch image. It says:

error while starting IOU1: License section not found in iourc file /tmp/tmpkrjoe5hx/iourc

Here’s how I solved it.

Section 1: Download and add IOU Image on GNS3 VM

i) Download Cisco L2/L3 IOU image. Some of them can be found here. You can also Google it to download any specific image. I’m using i86bi-linux-l2-adventerprisek9-15.2d.bin for my L2 lab.

ii) Go to Preference > IOS on UNIX > IOU Devices and add the image.

iii) But when I tried to run the switch on GNS3. It shows a license error.

iv) When I check the license from Preference > IOS on UNIX, it’s emplty, no license is there.

 

Section 2: Generate and add the Cisco IOURC License

You need a licence for your GNS3 VM to run IOU. This licence is provided by Cisco. We called this licence file iourc.

The content of the licence file will be like this:

[license]
gns3vm = <16-character license>;

The license is actually generated by the Keygen with the combination of the hostname and the hostid and ioukey of your VM. The Keygen file is actually a Python script that looks like:

#! /usr/bin/python3
print(“*********************************************************************”)
print(“Cisco IOU License Generator – Kal 2011, python port of 2006 C version”)
import os
import socket
import hashlib
import struct
# get the host id and host name to calculate the hostkey
hostid=os.popen(“hostid”).read().strip()
hostname = socket.gethostname()
ioukey=int(hostid,16)
for x in hostname:
ioukey = ioukey + ord(x)
print(“hostid=” + hostid +”, hostname=”+ hostname + “, ioukey=” + hex(ioukey)[2:])
# create the license using md5sum
iouPad1 = b’\x4B\x58\x21\x81\x56\x7B\x0D\xF3\x21\x43\x9B\x7E\xAC\x1D\xE6\x8A’
iouPad2 = b’\x80′ + 39*b’\0′
md5input=iouPad1 + iouPad2 + struct.pack(‘!i’, ioukey) + iouPad1
iouLicense=hashlib.md5(md5input).hexdigest()[:16]
print(“\nAdd the following text to ~/.iourc:”)
print(“[license]\n” + hostname + ” = ” + iouLicense + “;\n”)
with open(“iourc.txt”, “wt”) as out_file:
out_file.write(“[license]\n” + hostname + ” = ” + iouLicense + “;\n”)
print(“^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAlready copy to the file iourc.txt\n “)
print(“You can disable the phone home feature with something like:”)
print(” echo ‘127.0.0.127 xml.cisco.com’ >> /etc/hosts\n”)

Here’s how to generate the license using the Keygen.

i) Access the shell of your VM

ii) Download the Keygen in the directory /opt/gns3/images/IOU using the following command.

wget http://www.ipvanquish.com/download/CiscoIOUKeygen3f.py

iii) Once copied run the following command to generate the license.

python3 CiscoIOUKeygen3f.py

iii) Now, you can see that there is a new text file created named iourc.txt. It’s the file holding the license. You can open it to see the license.

iv) Now add the license to the empty field at Preference > IOS on UNIX. There you go, your IOU image will now run absolutely error free.

22 Replies to “Generate Cisco IOURC license on GNS3 VM using Python 3

  1. Thank you Sir! Your details here are very much appreciated. I am using the latest GNS3 2.1.3 and couldn’t figure out L2 and L3 Switches due to the same problems you are describing.

    You seem to be using an older version of GNS3 here?
    Many thanks.

    1. Thanks Andy, appreciate your kind words. While I wrote the blog post, I used older version than 2.1.3 because that time it was the latest 😉

  2. Like Andrew Johnson, I, too, had trouble starting an IOU switch image – until I stumbled upon this page.

    As suggested in the Python script, I checked /etc/hosts on the GNS3 VM, but it already contains an entry to blackhole xml.cisco.com. I have the GNS3 VM bridged to the same subnet as my home LAN so it could potentially phone home to Cisco. However the GNS3 VM has no “iface eth0 inet6 dhcp” line in /etc/network/interfaces (isn’t using IPv6 itself) so no worries there.

    (Actually, I should probably put the GNS3 VM back on a host-only network after I finish typing this, and configure the GNS3 server to start on that network.)

    Thank you again!

  3. i have question in my mind. what is best sulotion without CISCO VIRL to put virtual switch or router behind valid ip on internet?

  4. I managed to execute the keygen succesfully, but I cant seem to find the license .txt file. it is not appearing in my preferences.

  5. Hello, Thanks, very helpful, but I had to find out further to finish the task. when I generated the license in shell, It didnt added it as license file in GNS3, so I made new text document named IOURC and I wrote there content from shell-generated license text file, I dont know why it didnt appear dirrectly in gns3. but it worked. I hope It helps anyone

Leave a Reply

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