Chinaunix首页 | 论坛 | 博客
  • 博客访问: 705737
  • 博文数量: 67
  • 博客积分: 3148
  • 博客等级: 中校
  • 技术积分: 1084
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-10 14:33
文章分类

全部博文(67)

文章存档

2013年(2)

2012年(11)

2011年(33)

2010年(21)

我的朋友

分类: 系统运维

2010-11-29 17:35:34

   最近对SNMPV3产生一点兴趣,苦于手头没有多余电脑,也没有支持snmp v3的网络设备,于是想搭建一个虚拟的网络环境:VMWare(AS4)+Dynamips(Cisco7206VXR)桥接模式。利用这个环境对以后的学习也将会是受益匪浅的。
   想要达到的效果:
   1.VMWare上安装AS4.0系统,并安装net-snmp服务及snmp工具(snmpget\snmpwalk等)
   2.Dynamips(Cisco7206VXR)添加一个FE接口(F0/0)
   3.VMWare(AS4)和Dynamips(Cisco7206VXR)进行桥接模式的连接
 
 一、Dynamips环境搭建
     下载 dynagen-0.11.0_win_setup.exe并进行安装。安装的文件其实都是绿色文件,为了少敲键盘,我复制到d:\dynamips目录下。调试过程如下:

     1.准备一个cisco ios,网上找了一个unzip-c7200-advsecurityk9-mz.124-11.T.bin,放在d:\dynamips\images目录下。

     2.建立自己dynagen批处理文件,放在d:\dynamips下,文件名:自己的测试环境.cmd,内容如下:   
@echo off
echo * 我自己的环境                        *
echo *=====================================
.\dynagen.exe .\sample_labs\mytest.net

     3.建立网络拓扑(.net文件)
      统一放在D:\Dynamips\sample_labs下,文件名为:mynet.net,内容如下:

autostart = False

[localhost]
    port = 7200
    udp = 10000
    #workingdir = ..\tmp\
   
    [[router R1]]
        image = d:\dynamips\images\unzip-c7200-advsecurityk9-mz.124-11.T.bin
        model = 7200
        console = 3001
        npe = npe-400
        ram = 160
        confreg = 0x2102
        exec_area = 64
        mmap = False
        slot0 = PA-C7200-IO-FE
        f0/0 = NIO_gen_eth:\Device\NPF_{423110F3-F261-4764-BE9E-D34C03719D32}
    #这串字符是通过运行 "D:\Dynamips\network device list.cmd"得到VMnet1的值,后面再详细说说为什么取vmnet1的值。

     4. 通过运行"D:\Dynamips\dynamips-start.cmd"来启动dynamips后台程序,通过运行"D:\Dynamips\自己的测试环境.cmd"来加载IOS和自己的测试拓扑。

            Reading configuration file...

Network successfully loaded

Dynagen management console for Dynamips and Pemuwrapper 0.11.0
Copyright (c) 2005-2007 Greg Anuzelli, contributions Pavel Skovajsa

=> list
Name       Type       State      Server          Console
R1         7200       stopped    localhost:7200  3001
=> start R1
Warning: Starting R1 with no idle-pc value  //不带idle-pc value,不管你虚拟了几天路由器,宿主主机的cpu都将是100%,
100-VM 'R1' started
=> idlepc get R1  //进行idlepc操作是为了降低宿主主机的cpu使用率
Please wait while gathering statistics...
   1: 0x61279800 [35]
   2: 0x624b1818 [73]
*  3: 0x60e718cc [54]
   4: 0x6176232c [47]
   5: 0x61272d18 [48]
   6: 0x61272d40 [37]
   7: 0x61272f18 [43]
   8: 0x61272f8c [33]
   9: 0x61273064 [65]
  10: 0x61273954 [29]
Potentially better idlepc values marked with "*"
Enter the number of the idlepc value to apply [1-10] or ENTER for no change: 3
Applied idlepc value 0x60e718cc to R1
=> idlepc save R1 db
idlepc value for image "unzip-c7200-advsecurityk9-mz.124-11.T.bin" written to th
e database


二、VMware(AS4)调试
      在VM上安装AS4系统就不多介绍了,为了实现我们的目标,我们在VM中设置网卡的时候选择桥接模式下的VMnet1,然后启动AS4系统。


      
三、连通测试
      两个虚拟系统都正常启动之后,ping对方地址,ping通说明环境就搭建好了。

四、疑难点解释:
    1. 为何要选择vmnet1
    安装VMWare之后,会自动添加两个网卡,VMnet1和VMnet8, VMnet1是”透明“的桥接模式,VMnet8是经过NAT之后的桥接模式,为了简化问题,最好选择Vmnet1。


    2.dynmips中的idlepc操作的作用
    看到idle的名称,我们就会联想到任务管理器中"system idle process”进程,其实意义是一样的,表示剩余可利用资源,通过名称大概就能猜出这个命令的作用了。
    这个因为dynamips不知道虚拟路由什么时候处于空闲状态,什么时候处于使用状态。”idlepc”命令协助分析正在运行的印象文件,在执行代码中测定一个最有可能的点,在IOS中描绘一个空闲循环周期。一旦应用,dynamips在空闲循环周期被执行的时候偶尔”休眠”虚拟路由器,当然这不会在实际操作中降低虚拟路由器的处理能力。主要是大幅度的降低主机的CPU消耗。再看看idlepc的help:

=> help idlepc
idlepc {get|set|copy|show|save|idlemax|idlesleep|showdrift} device [value]
        get, set, or show the online idlepc value(s)
Examples:
  idlepc get r1
        Get a list of the possible idlepc value(s) for router r1
  idlepc show r1
        Show the previously determined idlepc values for router r1
  idlepc set r1 0x12345
        Manually set r1's idlepc to 0x12345
  idlepc copy r1 /all
        Set the same idlepc as on r1 for all routers that have the same IOS as r
1
  idlepc save r1
        Save r1's current idlepc value to the "router r1" section of your networ
k file
  idlepc save r1 default
        Save r1's current idlepc value to the device defaults section of your ne
twork file (i.e. [[7200]])
  idlepc save r1 db
        Save r1's current idlepc value to the idlepc database
  idlepc idlemax r1 1500
        Set the idlemax parameter for "router r1". Use /all instead to set on al
l routers.
  idlepc idlesleep r1 30
        Set the idlesleep parameter for "router r1". Use /all instead to set on
all routers.
  idlepc showdrift r1
        Display the drift of idlepc on "router r1"

阅读(3159) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-30 10:57:45

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com