如何使用两台主机实现三个网段之间互通且三个网段均可联网
来源:互联网 发布:淘宝酒类授权怎么写 编辑:程序博客网 时间:2024/05/21 06:33
版权声明:对于本博客所有原创文章,允许个人、教育和非商业目的使用,但务必保证文章的完整性且不作任何修改地以超链接形式注明原始作者、出处及本声明。
博客地址:http://blog.csdn.net/shuxiao9058
原始作者:季亚
step1:搭建网络拓扑
首先,图1是我们在实验室所搭建的网络拓扑结构,其中192.168.1.*为我们实验室的内网,210.28.164.11通往外网,我们所要实现的功能就是使A、B、C三网段网络互通,且三网段可以使用210.28.164.11这个IP连接到外网上网。
图1 网络拓扑
网络拓扑注解:上面两台主机是我们欲做路由器且装有多个网卡和LInux操作系统的PC机,其中Route1装有两个网卡,其中一个网卡(设备名eth1)的IP地址为192.168.1.250,另一个网卡(设备名eth0)的IP地址为192.168.2.254;而Route2装有三个网卡,其中一个网卡(设备名em1)是为了与外网相连的,它的IP地址为210.28.164.11,其余网卡(设备名为p1p1和p2p1)的IP地址分别为192.168.3.254和192.168.2.253。下面一层的设备是三个交换机,分别连接三个不同网段的内网,且我们使用三台主机号为5的机器进行测试三个网段之间的网络通畅情况。
注意:在进行连线的时候注意如果是PC机和交换机相连需要直连线,如果两台PC机之间相连则需要使用交叉线!另外,比较新的网卡有只能识别功能,因此直连线和交叉线均可,相关知识读者可以参考鸟哥的Linux私房菜 服务器架设篇(第二版)中Page26-27页中的内容。
网络拓扑搭建好了,下面我们来进行相关网络配置,首先我们要确认两台机器都装有Linux系统,笔者所使用的两台机器安装的操作系统分别为红帽5.5(Route1)企业版和Fedora15(Route2).详细信息如下:
Route1:
[root@localhost ~]# uname -aLinux localhost.localdomain 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02 EDT 2007 i686 i686 i386 GNU/Linux[root@localhost ~]#Route2:
[root@localhost ~]# uname -aLinux localhost.localdomain 2.6.40.6-0.fc15.i686.PAE #1 SMP Tue Oct 4 00:44:38 UTC 2011 i686 i686 i386 GNU/Linux[root@localhost ~]#
另外,还要确保两台机器都装有iptables,可使用rpm命令检查iptables组件是否安装:
Route1:
[root@localhost ~]# rpm -qa iptablesiptables-1.3.5-1.2.1[root@localhost ~]#Route2:
[root@localhost ~]# rpm -qa iptablesiptables-1.4.10-2.fc15.i686[root@localhost ~]#
如果机器中没有安装iptables,请通过Linux系统安装光盘/镜像文件或在网上搜索(http://rpm.pbone.net)下载获取安装iptables所需的软件包,并将该iptables安装软件拷贝至机器上进行安装。
step2:IP配置
根据图一中的拓扑结构依次配置两台主机的IP地址,如下所示:
Route1:
+-------+ Devernet Configuration +--------+ | | | | | Name eth1________________ | | Device eth1________________ | | Use DHCP [ ] | | Static IP 192.168.1.250_______ | | Netmask 255.255.255.0_______ | | Default gateway IP ____________________ | | | | +----+ +--------+ | | | Ok | | Cancel | | | +----+ +--------+ | | | | | +-----------------------------------------+ +-------+ Devernet Configuration +--------+ | | | | | Name eth0________________ | | Device eth0________________ | | Use DHCP [ ] | | Static IP 192.168.2.254_______ | | Netmask 255.255.255.0_______ | | Default gateway IP 192.168.2.253_______ | | | | +----+ +--------+ | | | Ok | | Cancel | | | +----+ +--------+ | | | | | +-----------------------------------------+请注意Route1中eth0的默认网关的设置,不然A、B两个网段将不能正常上网。
Route2:
┌─────────────┤ 网络配置 ├─────────────┐ │ │ │ │ │ 名称 em1_________________ │ │ 设备 em1_________________ │ │ 使用 DHCP [ ] │ │ 静态 IP 210.28.164.11_______ │ │ 子网掩码 255.255.255.0_______ │ │ 默认网关 IP 210.28.164.254______ │ │ 主 DNS 服务器 61.155.18.30________ │ │ 第二 DNS 服务器 208.67.222.222______ │ │ │ │ ┌──────┐ ┌──────┐ │ │ │ 确定 │ │ 取消 │ │ │ └──────┘ └──────┘ │ │ │ │ │ └──────────────────────────────────────┘ ┌─────────────┤ 网络配置 ├─────────────┐ │ │ │ │ │ 名称 p1p1________________ │ │ 设备 p1p1________________ │ │ 使用 DHCP [ ] │ │ 静态 IP 192.168.3.254_______ │ │ 子网掩码 255.255.255.0_______ │ │ 默认网关 IP ____________________ │ │ 主 DNS 服务器 61.155.18.30________ │ │ 第二 DNS 服务器 208.67.222.222______ │ │ │ │ ┌──────┐ ┌──────┐ │ │ │ 确定 │ │ 取消 │ │ │ └──────┘ └──────┘ │ │ │ │ │ └──────────────────────────────────────┘ ┌─────────────┤ 网络配置 ├─────────────┐ │ │ │ │ │ 名称 p2p1________________ │ │ 设备 p2p1________________ │ │ 使用 DHCP [ ] │ │ 静态 IP 192.168.2.253_______ │ │ 子网掩码 255.255.255.0_______ │ │ 默认网关 IP ____________________ │ │ 主 DNS 服务器 61.155.18.30________ │ │ 第二 DNS 服务器 208.67.222.222______ │ │ │ │ ┌──────┐ ┌──────┐ │ │ │ 确定 │ │ 取消 │ │ │ └──────┘ └──────┘ │ │ │ │ │ └──────────────────────────────────────┘备注:上面部分配置信息无意义,请注意使用的均是静态IP,不要勾选DHCP选项。
step3:重启网络
配置完成之后,请输入下面命令重启网络:
Route1:
[root@localhost ~]# service network restart正在关闭接口 eth0: [确定]正在关闭接口 eth1: [确定]关闭环回接口: [确定]禁用 IPv4 包转送: net.ipv4.ip_forward = 0[确定]弹出环回接口: [确定]弹出界面 eth0: [确定]弹出界面 eth1: [确定][root@localhost ~]#
Route2:
[root@localhost ~]# service network restartRestarting network (via systemctl): [确定][root@localhost ~]#
注意:请注意网络是否正常开启,如有问题,请查阅相关资料,解决后继续下面工作。
重启网络后可以查看系统中默认的路由信息:
Route1:
[root@localhost ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1[root@localhost ~]#
Route2:
[root@localhost ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 210.28.164.254 0.0.0.0 UG 0 0 0 em1192.168.2.0 0.0.0.0 255.255.255.0 U 1 0 0 p2p1192.168.3.0 0.0.0.0 255.255.255.0 U 1 0 0 p1p1192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 p1p1210.28.164.0 0.0.0.0 255.255.255.0 U 1 0 0 em1[root@localhost ~]#从上面的路由表信息中可以知道,系统会自动根据网卡的IP地址信息给网卡添加默认路由信息,如在Route1中设备eth0的IP地址为192.168.2.254,系统会自动给它添加192.168.2.*网段的路由信息;在Route2中设备p2p1的IP地址为192.168.2.253,系统会自动给它添加192.168.2.*网段的路由信息。由以上信息可知由Route1可以通过192.168.2.253直接ping通Route2,但是不能通过192.168.3.254ping通Route2,因为没有到从192.168.2.*或者192.168.1.*到192.168.3.*的路由路径,反向也是如此。
step4:启动系统IP转发(这一步非常重要,其他操作都完成了,但是网络还是不通畅大多都是这个问题)
[root@localhost ~]# vi /etc/sysctl.conf # Kernel sysctl configuration file for Red Hat Linux## For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and# sysctl.conf(5) for more details.# Controls IP packet forwardingnet.ipv4.ip_forward = 1# Controls source route verificationnet.ipv4.conf.default.rp_filter = 1# Do not accept source routingnet.ipv4.conf.default.accept_source_route = 0# Controls the System Request debugging functionality of the kernelkernel.sysrq = 0# Controls whether core dumps will append the PID to the core filename# Useful for debugging multi-threaded applicationskernel.core_uses_pid = 1# Controls the use of TCP syncookiesnet.ipv4.tcp_syncookies = 1"/etc/sysctl.conf" 35L, 994C written[root@localhost ~]# service network restart正在关闭接口 eth0: [确定]正在关闭接口 eth1: [确定]关闭环回接口: [确定]弹出环回接口: [确定]弹出界面 eth0: [确定]弹出界面 eth1: [确定][root@localhost ~]#操作完成后,记得重新启动下网络,最后检查确认IP转发功能的状态,可以查看/proc文件系统中的/proc/sys/net/ipv4/ip_forward状态值,如果该值为0,说明当前系统禁止进行IP转发;如果是1,则说明系统的IP转发功能已经打开。操作命令如下所示:
[root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward 1[root@localhost ~]#
step5:添加路由信息
[root@localhost ~]# route add -net 192.168.2.0/24 eth0[root@localhost ~]# route add -net 192.168.3.0/24 eth0同样,在Route2也无需添加如下路由信息:
[root@localhost ~]# route add -net 192.168.1.0/24 p2p1[root@localhost ~]# route add -net 192.168.2.0/24 p2p1[root@localhost ~]# route add -net 192.168.3.0/24 p1p1即只需在路由表中添加非0.0.0.0网关的路由信息,添加命令操作如下。
[root@localhost ~]# route add -net 192.168.3.0/24 gw 192.168.2.253 eth0[root@localhost ~]# route add -net 192.168.2.0/24 gw 192.168.2.253 eth0[root@localhost ~]#
下面是我在A网段中的一台IP地址为192.168.1.5,网关为192.168.1.250的PC机中的操作:
Microsoft Windows XP [版本 5.1.2600](C) 版权所有 1985-2001 Microsoft Corp.C:\Documents and Settings\jiya>ping 192.168.1.250Pinging 192.168.1.250 with 32 bytes of data:Reply from 192.168.1.250: bytes=32 time<1ms TTL=64Ping statistics for 192.168.1.250: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0msControl-C^CC:\Documents and Settings\jiya>ping 192.168.3.254Pinging 192.168.3.254 with 32 bytes of data:Reply from 192.168.3.254: bytes=32 time<1ms TTL=63Ping statistics for 192.168.3.254: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0msControl-C^CC:\Documents and Settings\jiya>ping 192.168.3.5Pinging 192.168.3.5 with 32 bytes of data:Reply from 192.168.3.5: bytes=32 time<1ms TTL=62Reply from 192.168.3.5: bytes=32 time<1ms TTL=62Ping statistics for 192.168.3.5: Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0msControl-C^CC:\Documents and Settings\jiya>tracert 192.168.3.5Tracing route to 192.168.3.5 over a maximum of 30 hops 1 <1 ms * * 192.168.1.250 2 <1 ms <1 ms <1 ms 192.168.2.253 3 <1 ms <1 ms <1 ms 192.168.3.5Trace complete.C:\Documents and Settings\jiya>
Route2中的操作命令如下所示:
[root@localhost ~]# route add -net 192.168.1.0/24 gw 192.168.2.254 p2p1[root@localhost ~]# route add -net 192.168.2.0/24 gw 192.168.2.254 p2p1[root@localhost ~]#这样便可以实现由Route1通过192.168.3.254访问Route2了,操作命令如下所示:
[root@localhost ~]# ping 192.168.3.254PING 192.168.3.254 (192.168.3.254) 56(84) bytes of data.64 bytes from 192.168.3.254: icmp_seq=1 ttl=64 time=1.11 ms64 bytes from 192.168.3.254: icmp_seq=2 ttl=64 time=0.127 ms64 bytes from 192.168.3.254: icmp_seq=3 ttl=64 time=0.145 ms64 bytes from 192.168.3.254: icmp_seq=4 ttl=64 time=0.144 ms--- 192.168.3.254 ping statistics ---4 packets transmitted, 4 received, 0% packet loss, time 2999msrtt min/avg/max/mdev = 0.127/0.381/1.111/0.421 ms[root@localhost ~]#
Step6:IP伪装配置(为内网IP做端口映射)
如此,虽然我们这三个内网可以互通网络,但是我们还是不能在这A、B、C网段内上网,操作命令如下所示:[root@localhost ~]# ping www.baidu.comping: unknown host www.baidu.com[root@localhost ~]#
[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE[root@localhost ~]# service iptables save将当前规则保存到 /etc/sysconfig/iptables:[确定][root@localhost ~]# service iptables restart清除防火墙规则:[确定]把 chains 设置为 ACCEPT 策略:nat filter [确定]正在卸载 Iiptables 模块:[确定]应用 iptables 防火墙规则:[确定]载入额外 iptables 模块:ip_conntrack_netbios_ns [确定][root@localhost ~]#
类似的,在Route2中,我们也可以通过NAT防火墙进行IP地址伪装,操作命令如下所示:
[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o em1 -j MASQUERADE[root@localhost ~]# iptables -t nat -A POSTROUTING -s 192.168.3.0/24 -o em1 -j MASQUERADE[root@localhost ~]# service iptables saveiptables:将防火墙规则保存到 /etc/sysconfig/iptables:[确定][root@localhost ~]# service iptables restartRestarting iptables (via systemctl): [确定][root@localhost ~]#
step7:测试
[root@localhost ~]# ping www.baidu.comPING www.a.shifen.com (119.75.218.45) 56(84) bytes of data.64 bytes from 119.75.218.45: icmp_seq=1 ttl=49 time=26.0 ms64 bytes from 119.75.218.45: icmp_seq=2 ttl=49 time=26.0 ms64 bytes from 119.75.218.45: icmp_seq=3 ttl=49 time=26.2 ms64 bytes from 119.75.218.45: icmp_seq=4 ttl=49 time=25.9 ms64 bytes from 119.75.218.45: icmp_seq=5 ttl=49 time=26.0 ms64 bytes from 119.75.218.45: icmp_seq=6 ttl=49 time=26.2 ms64 bytes from 119.75.218.45: icmp_seq=7 ttl=49 time=26.0 ms--- www.a.shifen.com ping statistics ---7 packets transmitted, 7 received, 0% packet loss, time 5999msrtt min/avg/max/mdev = 25.966/26.084/26.228/0.214 ms[root@localhost ~]# traceroute www.baidu.comtraceroute to www.baidu.com (119.75.217.56), 30 hops max, 40 byte packets 1 192.168.2.253 (192.168.2.253) 0.146 ms 0.085 ms 0.082 ms 2 (210.28.164.254) 1.111 ms 1.108 ms 1.112 ms 3 172.18.32.254 (172.18.32.254) 2.851 ms 2.834 ms 2.809 ms 4 10.29.0.201 (10.29.0.201) 0.784 ms 0.781 ms 0.831 ms 5 * * * 6 202.119.128.229 (202.119.128.229) 8.992 ms 9.452 ms 9.933 ms 7 202.119.128.2 (202.119.128.2) 8.089 ms 8.113 ms 8.153 ms 8 zhz0.cernet.net (202.112.38.113) 8.257 ms 8.264 ms 8.278 ms 9 202.112.53.25 (202.112.53.25) 8.397 ms 8.733 ms 8.794 ms10 202.112.62.57 (202.112.62.57) 31.151 ms 31.138 ms 31.244 ms11 202.112.62.242 (202.112.62.242) 25.516 ms 25.557 ms 25.639 ms12 202.112.6.54 (202.112.6.54) 26.034 ms !X * *[root@localhost ~]#由以上的信息可以知道Route1可以上网。
下面是我在A网段中的一台IP地址为192.168.1.5,网关为192.168.1.250的PC机中的操作:
Microsoft Windows XP [版本 5.1.2600](C) 版权所有 1985-2001 Microsoft Corp.C:\Documents and Settings\jiya>ipconfigWindows IP ConfigurationEthernet adapter VMware Network Adapter VMnet8: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.11.1 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :Ethernet adapter VMware Network Adapter VMnet1: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.110.1 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . :Ethernet adapter 本地连接: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.1.5 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.250C:\Documents and Settings\jiya>ping www.qq.comPinging www.qq.com [125.39.127.22] with 32 bytes of data:Reply from 125.39.127.22: bytes=32 time=134ms TTL=46Reply from 125.39.127.22: bytes=32 time=139ms TTL=46Reply from 125.39.127.22: bytes=32 time=137ms TTL=46Ping statistics for 125.39.127.22: Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 134ms, Maximum = 139ms, Average = 136msControl-C^CC:\Documents and Settings\jiya>tracert www.qq.comTracing route to www.qq.com [125.39.127.22]over a maximum of 30 hops: 1 <1 ms <1 ms <1 ms 192.168.1.250 2 <1 ms <1 ms <1 ms 192.168.2.253 3 1 ms 2 ms 1 ms 210.28.164.254 4 <1 ms <1 ms <1 ms 172.18.32.254 5 7 ms <1 ms <1 ms 10.29.0.201 6 * * * Request timed out. 7 8 ms 8 ms 8 ms 202.119.128.229 8 8 ms 8 ms 8 ms 202.119.128.2 9 8 ms 8 ms 8 ms zhz0.cernet.net [202.112.38.113] 10 8 ms 8 ms 8 ms 202.112.53.25 11 14 ms 19 ms 14 ms 202.112.36.38 12 14 ms 14 ms 13 ms 202.112.53.202 13 139 ms 141 ms 142 ms 219.158.34.121 14 141 ms 139 ms 139 ms 219.158.5.229 15 31 ms 31 ms 31 ms 219.158.96.49 16 152 ms 151 ms 155 ms 219.158.13.250 17 157 ms 157 ms 156 ms 202.99.66.106 18 132 ms 134 ms 133 ms 125.39.81.134 19 138 ms 134 ms 134 ms 125.39.127.22Trace complete.C:\Documents and Settings\jiya>由以上的信息可以知道A网段中的PC可以正常上网。
Microsoft Windows XP [版本 5.1.2600](C) 版权所有 1985-2001 Microsoft Corp.C:\Documents and Settings\Admin>ipconfigWindows IP ConfigurationEthernet adapter 本地连接: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.2.5 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.2.253C:\Documents and Settings\Admin>ping www.baidu.comPinging www.a.shifen.com [119.75.218.45] with 32 bytes of data:Reply from 119.75.218.45: bytes=32 time=26ms TTL=49Reply from 119.75.218.45: bytes=32 time=26ms TTL=49Reply from 119.75.218.45: bytes=32 time=26ms TTL=49Ping statistics for 119.75.218.45: Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 26ms, Maximum = 26ms, Average = 26msControl-C^CC:\Documents and Settings\Admin>tracert www.baidu.comTracing route to www.a.shifen.com [119.75.218.45]over a maximum of 30 hops: 1 <1 ms <1 ms <1 ms 192.168.2.253 2 1 ms 1 ms 1 ms 210.28.164.254 3 <1 ms <1 ms <1 ms 172.18.32.254 4 <1 ms <1 ms <1 ms 10.29.0.201 5 * * * Request timed out. 6 8 ms 8 ms 8 ms 202.119.128.229 7 8 ms 8 ms 8 ms 202.119.128.2 8 8 ms 8 ms 8 ms 202.112.38.109 9 8 ms 8 ms 8 ms 202.112.53.25 10 30 ms 30 ms 30 ms bj-11-p11-1.cernet.net [202.112.46.5] 11 * 25 ms * cd1.cernet.net [202.112.53.74] 12 25 ms 26 ms 25 ms 202.112.6.58 13 31 ms 31 ms 31 ms 192.168.0.5 14 26 ms 26 ms 26 ms 10.65.190.131 15 26 ms 26 ms 26 ms 119.75.218.45Trace complete.C:\Documents and Settings\Admin>
下面是我在B网段中的一台IP地址为192.168.2.5,网关为192.168.2.254的PC机中的操作:
Microsoft Windows XP [版本 5.1.2600](C) 版权所有 1985-2001 Microsoft Corp.C:\Documents and Settings\Admin>ipconfigWindows IP ConfigurationEthernet adapter 本地连接: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.2.5 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.2.254C:\Documents and Settings\Admin>ping www.baidu.comPinging www.a.shifen.com [119.75.218.45] with 32 bytes of data:Reply from 119.75.218.45: bytes=32 time=26ms TTL=49Reply from 119.75.218.45: bytes=32 time=26ms TTL=49Reply from 119.75.218.45: bytes=32 time=26ms TTL=49Ping statistics for 119.75.218.45: Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 26ms, Maximum = 26ms, Average = 26msControl-C^CC:\Documents and Settings\Admin>tracert www.baidu.comTracing route to www.a.shifen.com [119.75.218.45]over a maximum of 30 hops: 1 <1 ms <1 ms <1 ms 192.168.2.254 2 <1 ms <1 ms * 192.168.2.253 3 450 ms * * 210.28.164.254 4 191 ms 96 ms 374 ms 172.18.32.254 5 * 113 ms 35 ms 10.29.0.201 6 * * * Request timed out. 7 347 ms 471 ms 638 ms 202.119.128.229 8 278 ms 568 ms 71 ms 202.119.128.2 9 427 ms 343 ms * 202.112.38.109 10 * * * Request timed out. 11 708 ms * 617 ms bj-11-p11-1.cernet.net [202.112.46.5] 12 * * * Request timed out. 13 797 ms 509 ms 308 ms 202.112.6.58 14 569 ms 339 ms 376 ms 192.168.0.5 15 952 ms 464 ms 874 ms 10.65.190.131 16 214 ms 579 ms 550 ms 119.75.218.45Trace complete.C:\Documents and Settings\Admin>
由以上的信息我们可以知道在B网段中,无论我们使用192.168.2.253做网关,还是用192.168.2.254做网关,这个网段内的PC机均可以正常上网。只是用192.168.2.254做网段的机器上网的话需要多一次路由。下面是我在C网段中的一台IP地址为192.168.3.5,网关为192.168.3.254的PC机中的操作:
Microsoft Windows XP [版本 5.1.2600](C) 版权所有 1985-2001 Microsoft Corp.C:\Documents and Settings\Admin>ipconfigWindows IP ConfigurationEthernet adapter 本地连接: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.3.5 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.3.254C:\Documents and Settings\Admin>ping www.baidu.comPinging www.a.shifen.com [119.75.218.45] with 32 bytes of data:Reply from 119.75.218.45: bytes=32 time=395ms TTL=49Reply from 119.75.218.45: bytes=32 time=389ms TTL=49Reply from 119.75.218.45: bytes=32 time=520ms TTL=49Ping statistics for 119.75.218.45: Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 389ms, Maximum = 520ms, Average = 434msControl-C^CC:\Documents and Settings\Admin>tracert www.baidu.comTracing route to www.a.shifen.com [119.75.218.45]over a maximum of 30 hops: 1 <1 ms <1 ms <1 ms 192.168.3.254 2 141 ms 416 ms 828 ms 210.28.164.254 3 326 ms 314 ms 196 ms 172.18.32.254 4 235 ms 145 ms * 10.29.0.201 5 * * * Request timed out. 6 414 ms 551 ms * 202.119.128.229 7 289 ms 246 ms 216 ms 202.119.128.2 8 * 404 ms 705 ms 202.112.38.109 9 * 407 ms 419 ms 202.112.53.25 10 180 ms 209 ms 281 ms bj-11-p11-1.cernet.net [202.112.46.5] 11 * * 354 ms cd1.cernet.net [202.112.53.74] 12 * 298 ms 555 ms 202.112.6.58 13 35 ms 37 ms 31 ms 192.168.0.5 14 153 ms 144 ms 181 ms 10.65.190.131 15 * * 27 ms 119.75.218.45Trace complete.C:\Documents and Settings\Admin>由以上的信息可以知道C网段中的PC可以正常上网。
[root@localhost ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface192.168.3.0 192.168.2.253 255.255.255.0 UG 0 0 0 eth0192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0192.168.2.0 192.168.2.253 255.255.255.0 UG 0 0 0 eth0192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth10.0.0.0 192.168.2.253 0.0.0.0 UG 0 0 0 eth0[root@localhost ~]#
Route2:
[root@localhost ~]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 210.28.164.254 0.0.0.0 UG 0 0 0 em1192.168.1.0 192.168.2.254 255.255.255.0 UG 0 0 0 p2p1192.168.2.0 0.0.0.0 255.255.255.0 U 1 0 0 p2p1192.168.3.0 0.0.0.0 255.255.255.0 U 1 0 0 p1p1192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 p1p1210.28.164.0 0.0.0.0 255.255.255.0 U 1 0 0 em1[root@localhost ~]#【版权声明】
如有疑问请咨询本人:http://t.qq.com/shuxiao9058
- 如何使用两台主机实现三个网段之间互通且三个网段均可联网
- Linux 不同网段两台主机相互ping通
- ABC三个网段的划分
- 不同网段的两台机器是如何通信的
- 如何判断两台电脑是不是在同一网段内
- 利用单个三层交换机实现不同vlan和不同网段之间互通(华为和cisco)
- 直连的两台不同网段的主机为什么ping不通
- 直连的两台不同网段的主机为什么ping不通
- Linux下如何实现不同网段之间的访问
- 子网掩码在多网段之间的互通问题分析
- 单臂路由 不同vlan不同网段之间互通
- 企业内部不同网段的服务器之间互通-配置示例
- 网段
- 网段
- 关于同网段内主机之间通信细节
- 如何使用UDP进行跨网段广播
- 如何使用UDP进行跨网段广播
- 如何使用UDP进行跨网段广播
- Ubuntu11.04无线网络已禁用或设备未就绪
- 利用事件自动处理程序从网上批量下载指定数据
- JSON lib框架转换JSON XML不再困难!
- 全局对象和函数内静态对象调用构造析构函数差异
- 如何在桌面右下角的时间位置一起显示日期
- 如何使用两台主机实现三个网段之间互通且三个网段均可联网
- HTML开发语言基础和c++少部分知识
- servlet,jsp批量删除
- Linux下ARM汇编语法
- 数据结构栈的应用之括号匹配
- (zs)数学类题目小结
- 用户研究:10种类型的IT人士性格分析
- strlen函数的实现
- 动态创建整形数组