Linux Ubuntu dynamips bundle Loopback Port

我在以前的文章《在 Linux Ubuntu 下安装 Cisco 7200 dynamips 模拟器》里介绍过如何在linux下使用dynamips,因为在linux下dynamips能发挥到极致。现在我又有了新的需求,就是在linux中让模拟器跟我的服务器进行通信,网上这方面的知识介绍的很少,以下是总结,希望能帮助向我一样需要帮助的人。

在这里,我顺便提下,由于我的服务器没有显示器,全部操作都是telnet和远程控制,所以大部分都需要命令进行执行,下面是最常用的命令:
———————————————————————-
在Windows XP下用 “ shutdown -s -f ” 可以强行关闭PC,用 “shutdown -r -f ” 是强行重启,记住 “ -f ” 必须打,不然执行不了。
在Linux下用 “ init 0” 进行关闭PC,用 “init 6” 进行重启设备。

对于dynamips绑定PC网卡,系统不同配置也不同,总的感觉Linux配置起来很方便:
[[Router R1]]
model = 7200
console = 6001
slot1 = PA-4T
s1/0 = R2 s1/0
f0/0 = NIO_tap:tap0

此时对比下载Windows上绑定网卡的命令:
[[Router R1]]
model = 7200
disk0 = 64
autostart = False
slot1 = PA-4T
s1/0 = R2 S1/0
F0/0 = NIO_gen_eth:\Device\NPF_{9F3C3488-677C-477A-8B2B-0EEC180DFEB5}

添加Loopback tap0 并配置:

1. 安装 uml-utilities
root@frank-desktop:/opt/net# apt-get install uml-utilities

2. 用tunctl启动tap0
root@frank-desktop:/opt/net# modprobe tun
root@frank-desktop:/opt/net# tunctl tap0
Create: tunctl [-b] [-u owner] [-g group] [-t device-name] [-f tun-clone-device]
Delete: tunctl -d device-name [-f tun-clone-device]

The default tun clone device is /dev/net/tun – some systems use
/dev/misc/net/tun instead

-b will result in brief output (just the device name)
root@frank-desktop:/opt/net# tunctl
Set ‘tap0’ persistent and owned by uid 0

3. 配置并激活tap0
root@frank-desktop:/opt/net# ifconfig tap0 10.1.1.2 netmask 255.255.255.0 up

4. 脚本
由于每次开机都需要自己手动激活tap0,感觉非常麻烦,所以自己手动写个简单的脚本放到“/etc/init.d/”下。
这是可以通过“/etc/init.d/xxx start”来激活脚本。
frank@frank-desktop:/etc/init.d$ more tap0
#! /bin/sh -e
tunctl -t tap0
ifconfig tap0 10.1.1.2 netmask 255.255.255.0 up

5. 安装sysv-rc-conf并设置
按以上步骤仍然不能实现自动启动,需要在ubuntu中安装 sysv-rc-conf并设置脚本级别:
root@frank-desktop:~# apt-get install sysv-rc-conf
设置级别很简单,直接略过。

至此,环回口tap0终于完成,以后重启会自动加载tap0并激活它。

本文出自 Frank's Blog

版权声明:


本文链接:Linux Ubuntu dynamips bundle Loopback Port
版权声明:本文为原创文章,仅代表个人观点,版权归 Frank Zhao 所有,转载时请注明本文出处及文章链接
你可以留言,或者trackback 从你的网站

留言哦

blonde teen swallows load.xxx videos