测试环境:
主机(linux): ip:192.168.168.1.119 netmask:255.255.0.0
另一台主机(xp): ip:192.168.1.133 netmask:255.255.0.0
网关: ip:192.168.0.3 netmask: 255.255.248.0
一, 我们可以查看一下路由表.(route 命令)
[user:dvr_linux] route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.3 0.0.0.0 UG 0 0 0 eth0 //公网路由信息 //U – Up, G – Gateway, H – Host
192.168.0.0 * 255.255.0.0 U 0 0 0 eth0 //局域网路由信息.
[user:dvr_linux]
Flags 可能出现的标志有:
U (route is up) 路由正常
H (target is a host) 主机路由
G (use gateway) 使用网关的间接路由
R (reinstate route for dynamic routing) 为动态选路恢复路由
D (dynamically installed by daemon or redirect) 该路由由选路进程或重定向动态创建
M (modified from routing daemon or rederict) 该路由已由选路进程或重定向修改
! (reject route) 阻塞路由
1.1 测试公网路由(切换到root用户下):
[root:dvr_linux] route //打印路由表
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.3 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.0.0 U 0 0 0 eth0
[root:dvr_linux] ping 8.8.8.8