安装准备:
下载 nistnet.2.0.12b.tar.gz
http://snad.ncsl.nist.gov/nistnet/
nistnet.2.0.12c.tar.gz
http://snad.ncsl.nist.gov/nistnet/
(Nistnet
是运行在
linux
平台下的,目前有
2.0.12b
和
c
两个版本,具体安装哪个版本要视
linux
内核而定,2.4.**以下的用
b,2.6.**的用
c,千万别安错了;kernel 2.6.*下问题比较多,不太好搞。
)
以下就以
Red Had 9
做个例子
一.安装系统
安装有
kernel 2.4.**的
linux,硬盘如果够大,建议
linxu
模块全部安装,大约
5G+;免的出错。
二.安装
NISTnet
(1)
安装
NISTNET
前重新生成新内核
(因为
NISTNET
的新版本用
RTC-real
time
clock,
以前老版本用
fast
timer,RTC
更稳定)
open CLI:
cd /usr/src/linux2.4.20-8 // kernel
文档目录
make mrproper //删除不稳定的.O
文件和.config
配置文件
make menuconfig //调出修改内核工具
to make sure:
Loadable module support -->
Set version information no all module symbols --off //又说按
M
键设置,
本人在设置的时候用的
N
键
Character devices -->
Enhanced Real Time Clock Suppot --M //按
M
键,设置
make dep //连接程序代码和函数库
make clean //删不必要的模块
make bzImage
//生成内核文件
cp
/usr/src/linux2.4.20-8/arch/i386/boot/bzImage
/boot/vmlinuz-2.4.20-8_new
//
该步骤可能会提示用户“没有该目录…”
,请检查所在目录,正确运用
cp
命令即可
make modules //编译外挂模块
make modules_install //安装编译完成的模块
make
install //把新的内核和相关文件复制到正确的目录,
并修改
grub.conf
文件,在
grub
菜单会添加一个新的内核启动选项(也可以自己修改)
// ----------------------------------------------------------
mkinitrd /boot/initrd-2.4.20-8_new.img 2.4.20-8
edit grub.conf (/boot/grub/grub.conf , add a new title and the root path) 编译启
动文件(title Red Hat Linux (2.4.20-8 new)
root (hd0,0)
kernel /vmlinuz-2.4.20-8_new ro root= /dev/hda?
initrd /initrd-2.4.20-8_new.img
)
//-----------------------------------------------------------
NistNet
安装配置 jerry -2008
第
2
页
Reboot
注意:从新内核引导;当重启过程中出现让你选择
kernel 的选项时要选择最新编译过的,就是最上
面的那个。
(2)安装
NISTNET
cd ~./NistNet //进入
NistNet
解压缩目录
./configure
make
make install
//安装完成,如果没有错误就下一步
(3)测试安装是否成功
cd ~./NistNet
./Load nistnet
cnistnet –u
//加载模块 &也可使用图像窗口,xnistnet –u
cnistnet –a 192.168.100.1 192.168.2.121
--drop 30 --delay 30
//
进行丢包及延时设定
Clinet
一端:执
ping
操作(
192.168.100.111 ping 192.168.2.121
)
对比执行
cnistnet –d 后的结果 //off
该功能
NistNet
安装配置 jerry -2008
第
3
页
显然执行
cnistnet –a[]后,有了丢包及延时,说明测试
ok!
有关
NISTNET 的命令,执行
cnistnet –h
即可看到 //or 执行
cnustnet
也可显示
[root@localhost root]# cnistnet -h
cnistnet: invalid option -- h
Usage: cnistnet <options> - must be root to run it.
-u up (on)
-d down (off)
-a src[:port[.protocol]] dest[:port[.prot]] [cos] add new
[--delay delay [delsigma[/delcorr]]]
[--drop drop_percentage[/drop_correlation]]
[--dup dup_percentage[/dup_correlation]]
[--bandwidth bandwidth]
[--drd drdmin drdmax [drdcongest]]
-r src[:port[.prot]] dest[:port[.prot]] [cos] remove
-s src[:port[.prot]] dest[:port[.prot]] [cos] see stats
-S src[:port[.prot]] dest[:port[.prot]] [cos] see stats continuously
[-n] -R read table (-n numerical format)
-D value debug on (value=1 minimal, 9 maximal)
-U debug off
-G global stats
-K kickstart the clock
-F flush the queues
NistNet
安装配置 jerry -2008
第
4
页
-h this help message
三.LINUX
路由设置
我们的
NISTNET
已经安装
OK!下面进行
LINUX
路由设置:
Linux
环境下双网卡主机
(1)、环境:
三台直接相连的计算机主机如图
CLINET 1<------>NISTnet<------>CLINET 2
其中
NISTnet
上有两块网卡
eth0、eth1,分别与
CLINET 1、CLINET 2
相连
(2)、需求:
将
NISTnet
配置为路由器模式,用来在
CLINET 1、CLINET 2
之间转发报文
(3)、方法:
将三台主机按照环境所要求用交叉线直接连网后,为三台主机分配网段并配置
IP
地址。
网段及
IP
地址分配如下:
------- --------------- ------------------ ------------------
主机名 所在网段 分配
IP 网关
CLINET 1: 192.168.100.0/24 192.168.100.111/24
192.168.100.1
NISTnet: 192.168.100.0/24 eth1:192.168.100.1/24 eth0
192.168.2.0/24 eth0:192.168.2.1/24 eth1
CLINET 2: 192.168.2.0/24 192.168.2.121/24
192.168.2.1
-------------------------------------------------------------------------
按照上表所示分别将主机
IP
地址配置好,其中要注意的是,要想使
NISTnet
具有报文转发功能,
在
NISTnet
上检查/proc/sys/net/ipv4/ip_forward
中的值是否为
1
命令:
#cat /proc/sys/net/ipv4/ip_forward
如果显示其值不为
1
而是
0 输入以下命令:
#echo 1 > /proc/sys/net/ipv4/ip_forward
//打开
IP
转发功能
打开包的转发功能通常情况执行以下步骤即可:
#echo 1 > /proc/sys/net/ipv4/ip_forward //打开
IP
转发
#iptables -t nat -F // 清除原有的
nat
表中的规则
#iptables -F //清除原有的
filter
有中的规则
#iptables -P FORWARD ACCEPT //缺省允许
IP
转发
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE //在公网出口进行地址伪装,这样即使以
后公网地址修改了也不用重新设置规则。