Ubuntu下安装dynamips+dynagen+3640基本路由实验

Ubuntu下安装dynamipc

1、安装flex、bison、M4 yacc
这些是libpcap的依赖。
[shell]sudo apt-get install flex m4 flex bison[/shell]

2、安装libpcap
libpcap是必须的
[shell]
wget http://www.tcpdump.org/release/libpcap-1.0.0.tar.gz
tar -xzvf libpcap-1.0.0.tar.gz
./configure
[/shell]

3、下载dynamips最新版本,做个软连接
[shell]
wget http://www.ipflow.utc.fr/dynamips/dynamips-0.2.8-RC2-x86.bin
cd /usr/lib
ln -s /home/liheyuan/dynamips-0.2.8-RC2-x86.bin dynamips
chmod +x dynamips
[/shell]

4、启动dynamips获取idel-pc
每次启动dynagen前需要启动dynamips -H 7200 &,并且必须用root帐户!!
[shell]
#必须修改root密码
sudo passwd root
#切换到root
su
#启动dynamips服务,Hypervisor TCP control port 在 7200上
nice dynamips -H 7200
[/shell]

下面获得idle-pc
[shell]
#idle-pc可以优化dynamips,提升性能(以3640路由器为例)
sudo dynamips -P 3600 -t 3640 /home/liheyuan/dynamips/ios/c3640-jk9o3s-mz.124-16.bin
[/shell]
第一个选项no,然后进入Route>
按ctrl+]松开后按i,会得到一对idle-pc数值,选择count大的那个?(据说每一个数值都要测试一下)。

注:根据资料显示,count越大的CPU占用越低,推测count越小,性能越高?如果用于实际,可能count要很小。

0x603e2690 (count=54)
0x603e26f0 (count=51)
0x603e2724 (count=67)
0x603e2738 (count=37)
0x60503b94 (count=41)
0x605ac2a8 (count=45)
0x605ac320 (count=24)
0x60504620 (count=30)
0x6050465c (count=43)
0x60504f04 (count=41)

如果不使用dynagen,在dynamips启动时候需要配置上述idle-pc,否则就直接dynamips -H 7200 &就可以了(在.net文件中配置)
[shell]
sudo dynamips -P 3600 -t 3640 --idle-pc 0x603e2724 /home/liheyuan/dynamips/ios/c3640-jk9o3s-mz.124-16.bin
[/shell]

5、下载dynagen
dynagen是dynamips的一个包装程序,简化dynamips的复杂配置。
[shell]
wget http://downloads.sourceforge.net/project/dyna-gen/dynagen%20source%20_%20Linux/dynagen%200.11.0/dynagen-0.11.0.tar.gz?use_mirror=cdnetworks-kr-1
[/shell]

6、使用dynagen运行simple.net

[shell]
#必须是su,sudo不行!
su
#启动net文件(下详)
dynagen /home/liheyuan/net/simple.net
[/shell]

7、网络拓扑概述

外网<---> R1 <eth0----F1/0> R0 <F0/0----vboxnet0> PC1

PC1:
ip 192.168.30.2
gw 192.168.30.1

R0(3640模拟路由):
F0/0 192.168.30.1
F1/0 192.168.1.20

R1(物理路由,通过eth0与R0相连接):
eth2 192.168.1.1

8、net文件(注意tab等不能变)

[shell]
# simple.net

[localhost]

[[3640]]
image = /home/liheyuan/dynamips/ios/c3640-jk9o3s-mz.124-16.bin
ram = 160

[[ROUTER R1]]
model = 3640
F0/0 = NIO_linux_eth:eth0
F1/0 = NIO_linux_eth:vboxnet0
[/shell]

9、配置路由器

[shell]
#进入设置模式
en
#进入conf模式
conf t

#配置F0/0
int f0/0
#配置F0/0 's IP
ip address 192.168.1.20 255.255.255.0
#生效
no shut
exit

#配置F1/0
int f1/0
#配置F1/0 's IP
ip address 192.168.30.1 255.255.255.0
#生效
no shut
exit

#配置静态路由表 注意最后这一条最关键!
en
conf t
ip route 192.168.30.0 255.255.255.0 192.168.30.2
ip route 192.168.1.0 255.255.255.0 192.168.1.1
ip route 0.0.0.0 0.0.0.0 192.168.1.1
[/shell]

10、开机PC0设置IP
然后可以ping通所有外网了,比如google.com

Leave a Reply

Your email address will not be published. Required fields are marked *