专注EITM CA展开“隐形翅膀”
3. 应用实例配置静态路由
在配置网络时,要为机器指定接收数据包时该包要经过的路径。在Linux系统中,提供一个命令route,这个命令可以为ifconfig命令配置的网卡设置静态路由。这种设置工作通常在/etc/rc.d/rc.inet1中引入,在系统引导时进行。网络结构如下:
图-1 网络结构

Linux 路由器包括三个网卡:
eht0 192.168.1.1
eht1 192.168.10.1
eht2 192.168.100.1
分别连接三个子网:
子网A 192.168.1.0/24
子网B 192.168.10.0/24
子网C 192.168.100.0/24
为了让三个子网中的计算机互相通信进行如下配置:
在Red Hat Linux 中默认的内核配置已经包含了路由功能,但默认并没有在系统启动时启用此功能。
在配置网络时,要为机器指定接收数据包时该包要经过的路径。在Linux系统中,提供一个命令route,这个命令可以为ifconfig命令配置的网卡设置静态路由。这种设置工作通常在/etc/rc.d/rc.inet1中引入,在系统引导时进行。网络结构如下:
图-1 网络结构

Linux 路由器包括三个网卡:
eht0 192.168.1.1
eht1 192.168.10.1
eht2 192.168.100.1
分别连接三个子网:
子网A 192.168.1.0/24
子网B 192.168.10.0/24
子网C 192.168.100.0/24
为了让三个子网中的计算机互相通信进行如下配置:
在Red Hat Linux 中默认的内核配置已经包含了路由功能,但默认并没有在系统启动时启用此功能。
配置三个网络接口# echo 1 > /proc/sys/net/ipv4/ip_foward
添加路由选项#ifconfig eth0 down
#ifconfig eth1 down
#ifconfig eth2 down
#ifconfig eth0 192.168.1.1 up
#ifconfig eth1 192.168.10.1 up
#ifconfig eth2 192.168.100.1 up
重新查看路由表#route add -net 192.168.1.0/24 eth0
#route add -net 192.168.10.0/24 eth1
#route add -net 192.168.100.0/24 eth2
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.100.0 * 255.255.255.0 U 0 0 0 eth2
192.168.10.0 * 255.255.255.0 U 0 0 0 eth1
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
127.0.0.1 * 255.0.0.0 U 0 0 0 l0
0
相关文章