前两天不是从哪个网站看到dynamips这个CISCO 7200路由器硬件模拟器,一看到这个就觉得这个很有搞头,这两天安装来用了一下,感觉很好,所以顺便写一篇BLOG记下安装过过程,以免忘记,也分享给有类似需求的朋友!
简介:
FreeBSD的好话就不多说了,效能高,内核占用资源小…………
dynamips一种模拟CISCO路由器硬件环境的软件,可运行在linux,windows,freebsd系统上。当然其它的模拟软件也很多,学过CISCO的朋友肯定用过一些。但其它模拟软件都只是模拟一些针对NA/NP考试的命令,拓扑要么固定,要么运行不是很稳定,命令不全,运行命令时和真实路由器也还是有一些差别的。而dynamips 模拟的是CISCO的硬件环境,也就是说可以直接运行CISCOIOS,运行和真实路由器完全相同。而且模拟7200/3600这些作为学习CISCO认证的朋友,难以得到实际操作机会的高端机型。我了解到这些后也是相当兴奋的。
dynagen 是一种dynamips的前端管理工具,利用它可以方便的建立多个路由器的实验环境。只是一个使dynamips更易于配置和管理的工具,它并不是必须的,但我强烈推荐使用。
优点:真接运行CISCO IOS,再现真实环境;可运行于linux,FreeBSD,Windows 等各种操作系统
缺点:对硬件(在运行多台路由器时CPU和内存要够好)要求高,配置较其它路由器模拟软件麻烦一些(主要是拓扑文件的配置)
软件安装:
安装FreeBSD
cvsup 更新ports树(FB6.1更新ports后才有dynagen)
安装dynamips
bsd# cd /usr/ports/emulators/dynamips/
bsd# make install clean
安装dynagen
bsd# cd /usr/ports/emulators/dynagen/
bsd# make install clean
准备CISCO 7200 IOS文件(这步我是先前在Windows XP里做的,FreeBSD中也可以完成)
在网上搜一下,在这里(
http://www.315safe.com/download/cisco/8063.shtml)下载的IOS是RAR文件,先用winrar解开,如果大小是2xM的话,这个文件应该还可以解压,把此文件的扩展名改成zip,再用winrar解压得到的应该就是50M左右的IOS文件了,把IOS文件完全解压的目的是不要让路由器在启动的时候解压IOS文件,可以加快路由器的启动速度。
准备拓扑文件
最好在网上找一些现成的拓扑文件,如果找不到就先用dynagen带的示例文件,位置如下:
%pwd
/usr/local/share/examples/dynagen/sample_labs
%ls
all_config_options.txt frame_relay simple1
ethernet_switch multiserver simple2
%
参考文档:
对于 dynagen的基本了解可以看一下dynagen的文档,位置如下:
%ll
total 78
-r--r--r-- 1 root wheel 76637 1 5 15:21 tutorial.htm
drwxr-xr-x 2 root wheel 1024 1 5 15:21 tutorial_files
%pwd
/usr/local/share/doc/dynagen
%
我使用中的拓扑文件如下,也是在网上找的,贴出来以方便大家复制生成自己的拓扑,
一般来说需要修改的地方我加了简单注释
autostart = false #启动dynagen时不自动启动路由器,如果配置文件中路由器较多时自动启动,系统会很久没有响应
[localhost]
workingdir = /home/xiao/dynagen/tmp/ #在dynagen运行时会生成很多文件,指定一个目录让它们都在一块,以方便管理
[[7200]]
image =/home/xiao/dynagen/IOS/C7200-JS.BIN #指定IOS文件,注意要用绝对路径,我使用~/dynagen类似的路径时,工作不正常
ram = 160
npe = npe-400
idlepc = 0x60720678 #针对不同的IOS要重新计算此数,详见上面提到的dynagen文档
slot1 = PA-4T
[[ROUTER R1]]
F0/0 = S1 1
s1/0 = F1 1
a4/0 = A1 1
[[router R2]]
F0/0 = S1 2
s1/0 = F1 2
a4/0 = A1 2
[[router R3]]
F0/0 = S1 3
s1/0 = F1 3
a4/0 = A1 3
[[router R4]]
F0/0 = S1 4
s1/0 = F1 4
a4/0 = A1 4
[[router R5]]
F0/0 = S1 5
s1/0 = F1 5
a4/0 = A1 5
[[router R6]]
F0/0 = S1 6
s1/0 = F1 6
a4/0 = A1 6
[[router SW1]]
F0/0 = S1 7
a4/0 = A1 7
[[router SW2]]
F0/0 = S1 8
a4/0 = A1 8
[[router BB]]
F0/0 = S1 9
F2/0 = S1 10
F3/0 = S1 11
a4/0 = A1 9
[[ATMSW A1]]
1:0:102 = 2:0:201
1:0:103 = 3:0:301
1:0:104 = 4:0:401
1:0:105 = 5:0:501
1:0:106 = 6:0:601
1:0:107 = 7:0:701
1:0:108 = 8:0:801
1:0:109 = 9:0:901
1:0:112 = 2:0:211
1:0:113 = 3:0:311
1:0:114 = 4:0:411
1:0:115 = 5:0:511
1:0:116 = 6:0:611
1:0:117 = 7:0:711
1:0:118 = 8:0:811
1:0:119 = 9:0:911
2:0:203 = 3:0:302
2:0:204 = 4:0:402
2:0:205 = 5:0:502
2:0:206 = 6:0:602
2:0:207 = 7:0:702
2:0:208 = 8:0:802
2:0:209 = 9:0:902
2:0:213 = 3:0:312
2:0:214 = 4:0:412
2:0:215 = 5:0:512
2:0:216 = 6:0:612
2:0:217 = 7:0:712
2:0:218 = 8:0:812
2:0:219 = 9:0:912
3:0:304 = 4:0:403
3:0:305 = 5:0:503
3:0:306 = 6:0:603
3:0:307 = 7:0:703
3:0:308 = 8:0:803
3:0:309 = 9:0:903
3:0:314 = 4:0:413
3:0:315 = 5:0:513
3:0:316 = 6:0:613
3:0:317 = 7:0:713
3:0:318 = 8:0:813
3:0:319 = 9:0:913
4:0:405 = 5:0:504
4:0:406 = 6:0:604
4:0:407 = 7:0:704
4:0:408 = 8:0:804
4:0:409 = 9:0:904
4:0:415 = 5:0:514
4:0:416 = 6:0:614
4:0:417 = 7:0:714
4:0:418 = 8:0:814
4:0:419 = 9:0:914
5:0:506 = 6:0:605
5:0:507 = 7:0:705
5:0:508 = 8:0:805
5:0:509 = 9:0:905
5:0:516 = 6:0:615
5:0:517 = 7:0:715
5:0:518 = 8:0:815
5:0:519 = 9:0:915
6:0:607 = 7:0:706
6:0:608 = 8:0:806
6:0:609 = 9:0:906
6:0:617 = 7:0:716
6:0:618 = 8:0:816
6:0:619 = 9:0:916
7:0:708 = 8:0:807
7:0:709 = 9:0:907
7:0:718 = 8:0:817
7:0:719 = 9:0:917
8:0:809 = 9:0:908
8:0:819 = 9:0:918
[[ETHSW S1]]
1 = dot1q 1
2 = dot1q 1
3 = dot1q 1
4 = dot1q 1
5 = dot1q 1
6 = dot1q 1
7 = dot1q 1
8 = dot1q 1
9 = dot1q 1
10 = dot1q 1
11 = dot1q 1
[[FRSW F1]]
1:102 = 2:201
1:103 = 3:301
1:104 = 4:401
1:105 = 5:501
1:106 = 6:601
1:112 = 2:211
1:113 = 3:311
1:114 = 4:411
1:115 = 5:115
1:116 = 6:611
2:203 = 3:302
2:204 = 4:402
2:205 = 5:502
2:206 = 6:602
2:213 = 3:312
2:214 = 4:412
2:215 = 5:512
2:216 = 6:612
3:304 = 4:403
3:305 = 5:503
3:306 = 6:603
3:314 = 4:413
3:315 = 5:513
3:316 = 6:613
4:405 = 5:504
4:406 = 6:604
4:415 = 5:514
4:416 = 6:614
5:506 = 6:605
5:516 = 6:615
准备目录,为dynagen指定一个目录管理方便些,我喜欢在xiao这个用户下运行dynagen所以建了下面这些目录:
/home/xiao/dynagen dynagen的主目录,相关文件都在这里,拓扑文件也直接存在这里了
/home/xiao/dynagen/IOS 把IOS 文件放在这里
/home/xiao/dynagen/tmp 存放dynagen运行时生成的文件,可以保存路由器的设置,所以要根据需要清空
运行dynagen
运行dynagen前先要运行dynamips于服务器模式(这里我走了一个弯路,先以为直接运行dynagen会自己启动dynamips,结果浪费了不少时间)
在gnome中开一个终端
%dynamips -H 7200
Cisco 7200 Simulation Platform (version 0.2.5-x86)
Copyright (c) 2005,2006 Christophe Fillot.
Hypervisor TCP control server started.
保持第一个终端运行状态,再开一个终端运行dynagen
%dynagen 12.2(5)t ccie.net #12.2(5)t ccie.net 是上面贴的拓扑文件的文件名
Reading configuration file...
Network successfully started
Dynagen management console for Dynamips
=> list
Name Type State Server Console
R1 7200 stopped localhost:7200 2000
R2 7200 stopped localhost:7200 2001
R3 7200 stopped localhost:7200 2002
R4 7200 stopped localhost:7200 2003
R5 7200 stopped localhost:7200 2004
R6 7200 stopped localhost:7200 2005
SW1 7200 stopped localhost:7200 2006
SW2 7200 stopped localhost:7200 2007
BB 7200 stopped localhost:7200 2008
F1 FRSW n/a localhost:7200 n/a
A1 ATMSW n/a localhost:7200 n/a
S1 ETHSW n/a localhost:7200 n/a
=> ?
Documented commands (type help <topic>):
========================================
clear filter idlepc push resume shell stop ver
exit help import py save show suspend
export hist list reload send start telnet
=>
到这步就自己看着办了,可用的命令在上面,对路由器的start,stop,telnet都是在这里操作。
不过在使用软件前最好计算好idelpc值,详细介绍请看dynagen的教程,不然运行一台路由器CPU占用也是100%,没办法运行很多台。
在我的机器上(R52: pm 1.86G,1G + FreeBSD6.1+gnome),运行以上配置start/all设备可以全部正常启动,不过CPU也占用100%够受的。相同的配置在windows中运行windows版本的这个软件只能启动6台路由器,当然CPU也是100%占用,内存也没有剩的。不过完全启动后,CPU会降下来不少的。看来机器足够好完全能够做自己的试验室,而且在这方面FreeBSD确实要强一些。