天天看点

GNS3中IOU授权、VPCS及QEMU使用问题笔记2021.11前言IOU/IOLVPCSQEMU虚拟机问题

前言

前段时间使用GNS3模拟了个CISCO环境,把学习到的东西和遇到了一些问题总结下。

个人的环境就一个笔记本电脑(Interl i7-7500U) + Fedora 35操作系统。

为何要使用GNS3而不用CISCO自己的模拟器,Packet Tracer功能对于CCNA还行再往后就不行了(模拟不了),现在还要注册才能下载使用;另外一个更高级的,名字及不住了,反正还要付费,用不起。当然还有EVE等,这个要安装虚拟机(当然还有裸机安装),虽然是B/S,但启动还比较慢,虚拟机又觉得太重量了。因此,对于我这个小小的笔记本(2核4线程)还是放弃了,加上fedora软件库里面也有GNS3(有点原教旨主义:)),所以选择了GNS3+IOU方式来玩玩(后面再介绍IOU)。

IOU/IOL

IOU(IOS ON UNIX),可以模拟三层路由以及二层交换,是思科公司在测试IOS时用的,用IOU可以做很多大型试验,并且资源占用率很小(对比dynamips)。当然使用时可以堪称IOL(Cisco IOS on Linux)。好像不足之处是只能模拟Ethernet和Serial口,对于我自己来说是够用了的。

配置IOU比较简单,看看GNS3的文档、界面和向导应该问题不大,IOU资源的话就得自己找找了,这个也不是太大的问题,普通搜索试试就可以了。

License For IOU

如果没有License,IOU设备是没法运行的,所幸这个CISCO没有卡死,可以自己生成,一般是一个python文件,这里给出python3的生成脚本:

#! /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('!L', 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")           

准备好上述py文件,赋予可执行权限后运行,会在当前py脚本的目录下生成一个iourc.text文件,这个文件就是license。将此license加载到GNS3的IOU Device授权即可,位置在:

'Edit'->'Perferences'->'IOS on UNIX'。

VPCS

QEMU虚拟机问题

Could not create 'hda' disk image: qemu-img returned with 1
...