注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 LCS2005客户端配置详解:L..
 帮助

linux网关设置实验


2007-08-06 11:13:11
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://yahoon.blog.51cto.com/13184/37077
linux网关设置实验
 
环境:
2linux:redhat 9
1XP
 
实验过程
1linux,两块网卡
eth0 192.168.0.1 接交换机与内网相连
eth1 192.168.0.100 连接modem 通过adsl拨号
route内容为
[root@dbpi ppp]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags        Metric    Ref    Use Iface
202.103.29.218  0.0.0.0         255.255.255.255               UH       0      0        0 ppp0
192.168.0.0     0.0.0.0         255.255.255.0                 U         0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0                   U         0      0        0 eth1
127.0.0.0       0.0.0.0         255.0.0.0                     U        0      0        0 lo
0.0.0.0         202.103.29.218  0.0.0.0                       UG      0      0        0 ppp0
 
另一台linux 一块网卡
eth0 192.168.0.111 网关设为192.168.0.1
查看route信息
[root@server1 /]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
可见缺省路由是指向0.1
 
在这台机上启动转发
[root@server1 /]# echo 1 > /proc/sys/net/ipv4/ip_forward
 
原来XP的客户机指向0.1上网,现在在0.111上启用了转发,可以把XP的网关指向0.111
XP上追踪,当指向0.111时信息如下:
C:\Documents and Settings\Administrator>tracert 202.103.24.68
Tracing route to ns.wuhan.net.cn [202.103.24.68]
over a maximum of 30 hops:
  1    <1 ms    <1 ms    <1 ms  192.168.0.111
  2    <1 ms    <1 ms    <1 ms  192.168.0.100
  3     *        *        *     Request timed out.
  4    22 ms    21 ms    21 ms  221.232.250.9
 
  8    22 ms    21 ms    22 ms  ns.wuhan.net.cn [202.103.24.68]
 
原来指向0.1时信息如下:
C:\Documents and Settings\Administrator>tracert 202.103.24.68
Tracing route to ns.wuhan.net.cn [202.103.24.68]
over a maximum of 30 hops:
  1    <1 ms    <1 ms    <1 ms  192.168.0.100
  2     *        *        *     Request timed out.
  3    21 ms    20 ms    21 ms  221.232.250.9
 
  7    21 ms    22 ms    21 ms  ns.wuhan.net.cn [202.103.24.68]
可以现在多了0.111这一跳.
 
111的机器上再加一个网络的ip
eth0:0    192.168.1.112
此时111route信息如下
[root@server1 /]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0         192.168.0.1     0.0.0.0         UG    1      0        0 eth0
XP的网关设为0.111, ping不通另一个子网的1.112.
需要再次启用转发
echo 1 > /proc/sys/net/ipv4/ip_forward
这样XP将网关设为0.111之后,既可以上外网,也可以访问另一个子网了.

本文出自 “yahoon的小屋” 博客,请务必保留此出处http://yahoon.blog.51cto.com/13184/37077





    文章评论
 
2007-08-06 21:49:37
留啦,下次做实验,再来看

 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: