前言
前段時間使用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
...