诺达ICT培训 发表于 2018-2-1 10:31:57

【诺达手札】思科L3 L2 IOU模拟器 迁移至RHEL 6.1

一、   IOU简介
Cisco IOU (Cisco IOS On Unix),IOU基于unix/linux环境,比之GNS3、小凡都要节省不少系统资源。
IOU包括以下文件:
i86bi_linux-adventerprisek9-ms                  // 带有IOS高级特性的IOU
i86bi_linux-ipbase-ms                        // 带有基本的IP路由功能的IOU
i86bi_linux-tpgen+ipbase-ms.PAGENT.4.7.0         // 带有基本的IP路由功能和流量生成工具的IOU
i86bi_linuxl2-upk9-ms.M                     // 带layer 2功能的IOU,
iourc                                       // license文件
NETMAP                                     // topology文件
wrapper-linux                              // IOU的管理控制器
   
二、   IOU的使用方法
1.   wrapper-linux的使用:
./wrapper-linux [-v] –m<image name> -p<port number> -- <iou options> <router id>
where <port number> is in the range <1024-65550>
all options after the '--' are passed to iou
[-v] : display version;
-m:指定IOU镜像
-p:指定用于telnet的端口,范围是1024-65550;
--:用于传递iou的参数。
   
2.    IOU用法:
以i86bi开头的文件都能使用一下参数
Usage:<image> <application> id
<image>: unix-js-m | unix-is-m | unix-i-m | …
<application id>: instance identifier (0 < id <= 1024)
Options:
-e <n>   number of Ethernet interface (default 2)// 指定etherne的模块数量
-s <n>   number of Serial interface (default 2)    // 指定serial的模块数量
-n <n>   Size of nvram in kb (default 16kb)    // 指定nvram的大小,默认16kb
-b <string>IOS debug string
-c <name>Configureation file name
-d          Generate debug information
-t          Netio message trace
-q          Supperss informational messages
-h          Display this help
-C         Turn off use of the host clock
-m <n>   Megabytes of router memory (default 128MB)// 指定路由器的内存,默认128M。
-L         Disable local console,use remote console// 关闭本地console,开启远程console。
-u<n>      UDP port base for distributed networks   // 基于分布式网络的UDP端口。
-R         Ignore options from the IOURC file   // 忽略IOURC文件
-U         Disable unix: file system location
-W         Dsiable watchdog timer
-N         Ingnore the NETMAP file             // 忽略NETMAP文件
   
IOU举例:
./ i86bi_linux-adventerprisek9-ms-p 2000 ---e 4 –s 4 1
-e 4// 配置4个Ethernet接口模块,每个模块4个接口,0-3;
-s 4// 配置4个serial 接口模块,每个模块4个接口,0-3;
1// 路由器的进程名
Serial为Ethernet+1
在此列中:
Ethernet 16个,e0/0 ---- e3/3;
Serial 16个, s4/0 ---- s7/3。
   
wrapper-linux使用举例:
./wrapper-linux –m./ i86bi_linux-adventerprisek9-ms-p 2000---e 4 –s 4 1&
   
三、   用NETMAP建立网络拓扑
NETMAP文件的书写格式:
   路由器实例名:插槽号/该插槽上的接口号
分布式书写格式:
   路由器实例名:插槽号/该插槽上的接口号@IP_Add | Hostname
   
NETMAP实例:
1:0/02:0/0
1:0/13:0/0
1:0/24:0/0
1:4/0@192.168.1.1 2:4/0@192.168.1.2
1:4/1@wesley.org3:4/1@linux.com
   
解析:1:0/0表示第一台路由器ethernet接口,第一个模块的第一个接口,即 e0/0;
      1:4/0 表示第一台路由器serial接口,第一个模块的第一个接口,即s4/0。
   
四、   迁移&互通
网上很多IOU基本都是使用cdlinux或者andlinux作为载体的,不是很方便更改top,局限性比较大,况且自己动手丰衣足食嘛。
   系统环境:VMware WorkStation 7.14
Red Hat Enterprise Linux 6.1
*Python-2.6
Openssl-0.9.8
IOU文件:L3&L2 IOU
(NETMAP、iourc 、i86bi_linux-adventerprisek9-ms、i86bi_linuxl2-upk9-ms.M、wrapper-linux、crack.py(破解L2IOU<达人作品,不知何人!>))
   
1、迁移
   >>>在RHEL 6.1的root下创建目录:
    #mkdir cisco_iou
>>>copy IOU文件至cisoc_iou目录:
   #cp i86b*wrap-linux NETMAP iourc cisco_iou
*>>>编译安装python-2.6:
   #./configure
#make & make install
#make clean
*>>>添加PATH:
#export PATH=/usr/local/bin/python2.6:$PATH
注:带*的是指如果服务器python低于2.6的情况下,当然除此之外还有yum、rpm等方法。
>>>安装openssl:
# cd ~                           
# rpm –ivh openssl-0.9.8-*.rpm
   >>>连接lib库
# ln –s /usr/lib/libcrypto.so.0.9.8e libcrypto.so.4
注:./wrapper-linux 会调用这个库文件,如果没有就会报错。在这很感谢撒加大神提供的解决思路和方法。
   
   >>>设置IOU运行级别
       # chmod 777 *       // 偷懒的做法
   >>>破解license
# python ./crack.py
注:此处很重要,该程序是为了获取license,L3&L2 IOU都能使用。此程序为互联网上流出,何人所写,不清楚,感谢作者的无私奉献。
   >>>修改iourc
# vi iourc
   
License格式:
   hostname= license_number;
准备工作基本上都做完了,至此可以测试一下L3&L2 IOU。测试命令参见上文。
   
2、搭建拓扑
   
说明:路由器使用L3IOU来模拟,而交换机则都通过L2IOU来模拟,至于PC可以使用L3IOU或者L2IOU皆可。
   
    >>>创建一个放置拓扑文件和启动脚本的目录:
# mkdir lab01
# mv NETMAP lab01
# cd lab01
   
    >>>创建拓扑文件
# vi NETMAP
# ! /bin/bash
# written by wesley
# date:2011/6/17
1:0/02:0/0
1:0/13:0/0
2:0/14:0/0
3:0/14:0/1
3:0/24:0/2
3:0/35:0/0
4:036:0/0
   
    >>>创建启动脚本:
# vi start
   
# !/bin/bash
# written by Wesley
# and thanks for 撒加、flyxj、残泪、棕鹰、骁鹰...
# anyone who is help me to improve !!!
   
exportNETMAP=../lab01/NETMAP         // 设置NEMAP的变量,将其添加至环境中
port=2000                                 // 设置端口变量
for ((i=1;i<7;i++));do
dport='expr $port + $i'
../wrapper-linux –m ./ i86bi_linux-adventerprisek9-ms –p $dport -- -e 2 –s 2 –R –U $i &
if (($i>2));then
../wrapper-linux –m ./ i86bi_linuxl2-upk9-ms.M –p $dport -- -e 4 –R –U $i&
fi
sleep 2
done
unset NETMAP                     // 将NETMAP从环境变量中取消
   
   >>>创建关闭IOU的stop:
# vi stop
   
# !/bin/bash
   
kill –HUP ` ps –a | grep wrapper-linux | awk '{print $1}'`    // 退出IOU
   
注:很多朋友都用的killall,但是我发现使用killall后并不能得到完全释放,当想再次试验的时候会提示地址已被使用。
页: [1]
查看完整版本: 【诺达手札】思科L3 L2 IOU模拟器 迁移至RHEL 6.1