GNS3添加网络设备

GNS3添加网络设备

使用GNS3模拟器搭建网络环境,操作小记,备忘。

搭建环境

  • 系统:ubuntu 18.04.2 LTS(Linux 4.15.0-48-generic #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    )

  • GNS3 2.1.16

  • 虚拟机virtualbox 6.0.4 r128413

GNS3安装

ubuntu 直接添加PPA源安装:

1
2
3
sudo add-apt-repository ppa:gns3/ppa
sudo apt-get update
sudo apt-get install gns3-gui

安装结束后,会出现关于dynamips报错。解决办法:

1
2
3
4
sudo add-apt-repository ppa:gns3/ppa
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install dynamips:i386

启动后,出现配置向导。

添加设备

添加模拟的设备可以通过本地的server,GNS3 VM来完成。

本地的server中的Dynamips中添加设备。

[edit]->[Preferences]->[Dynamips]->[IOS routers]

添加的设备即直接通过本地电脑的Dynapips来模拟。

添加IOU

添加GNS3 VM设备,需要先导入GNS3 VM虚拟机。从官网下载GNS3 VM,如本文所示,选择virtualbox版本。

下载后,选择导入虚拟机,打开virtualbox,操作如下:

[管理]->[导入虚拟电脑]->[选择下载的GNS VM文件]->[点击导入]

导入后,在GNS3中选择GNS3 VM。操作如下:

[edit]->[Preferences]->[GNS3 VM]->[enable GNS3 VM]->[select Virtualizatiom engine Virtualbox]->[Settings]->[select imported VM named GNS3 VM]->[Apply setting]->[OK]

选择启动GNS3 VM,选择虚拟化引擎,选择导入的GNS3 VM。

尝试启动GNS3 VM,启动后直接报错,vboxnet0相关,无法启动GNS3 VM。

解决办法,添加网络vboxnet0。操作步骤:

[管理]->[主机网络管理器]->[网络]->[创建]

默认创建的网络就是vboxnet0。其余选项保持默认不变,启用DHCP服务。

再次打开GNS3 VM,正常启动。

解决GNS3 VM启动问题后,即可添加IOU(IOS ON UNIX)。

操作步骤:

[edit]->[Preferences]->[IOS on UNIX]->[type the license key]

添加IOU需要cisco的许可密钥,本例中的许可密码如下:

1
2
[license]
gns3vm = 73635fd3b0a13ad0;

许可密码可以通过以下方式生成:

  1. 打开GNS3 VM,选择Shell菜单

  2. 下载生成脚本,并生成license:

1
2
wget http://www.ipvanquish.com/download/CiscoIOUKeygen3f.py
python3 CiscoIOUKeygen3f.py

生成的文件为.iourc。

1
2
3
4
5
Already copy to the file iourc.txt

You can disable the phone home feature with something like:

echo '127.0.0.127 xml.cisco.com' >> /etc/hosts

把生成的GNS VM license添加到IOU on UNIX中,后,即可添加IOU设备。

操作方法:

[edit]->[Preferenses]->[IOS on UNIX]->[IOU devices]->[new]

添加IOU镜像,添加后,即可直接通过VM来运行l2 switch l3 router设备。

IOU和.iourc文件在哪里找,可以度之。

license gen直接给脚本吧:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /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")

好了,操作记录补充结束。


GNS3添加网络设备
https://ywmy.xyz/2019/05/14/GNS3添加网络设备/
作者
ian
发布于
2019年5月14日
许可协议