免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 909 | 回复: 0
打印 上一主题 下一主题

linux网关设置实验 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-23 11:32 |只看该作者 |倒序浏览
               
                linux网关设置实验

环境:
2台linux:redhat 9
1台XP

实验过程
1台linux,两块网卡
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              192.168.0.111
  2              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              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
此时111的route信息如下
[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之后,既可以上外网,也可以访问另一个子网了.
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93926/showart_1875202.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP