今天新下了一个交换机镜像导入到了GNS3里面。
但是启动的时候报错:
Hostname "xx.xx" not found in iourc file /tmp/tmp8r1_jhqc/iourc error while starting Switch1: Hostname "xx.xx" not found in iourc file /tmp/tmp0c2mal4y/iourc Hostname "xx.xx" not found in iourc file /tmp/tmp0c2mal4y/iourc
打开iourc文件看了一下其实就是IOU的licences,也就是说我们的licences生成的有问题。
好吧,那就再生成一次。
$ python3.6 CiscoIOUKeygen3f.py
*********************************************************************
Cisco IOU License Generator - Kal 2011, python port of 2006 C version
hostid=a8c0cc02, hostname=git.test, ioukey=a8c0cf34
Traceback (most recent call last):
File "CiscoIOUKeygen3f.py", line 20, in <module>
md5input=iouPad1 + iouPad2 + struct.pack('!i', ioukey) + iouPad1
struct.error: 'i' format requires -2147483648 <= number <= 2147483647
脚本直接报错,‘i’ format requires -2147483648 <= number <= 2147483647
这么看来是数字溢出了,i代表32位int。那么也就是说ioukey溢出了。
查看代码,看一下ioukey是如何计算出来的:
hostid=os.popen("hostid").read().strip()
hostname = socket.gethostname()
ioukey=int(hostid,16)
for x in hostname:
ioukey = ioukey + ord(x)
hostname加上去的数不会很大,所以主要看hostid
$ hostid a8c0cc02
由此可见hostid的值直接就超出了限制。问题解决。