近日在机房讨论组网问题,当讨论到路由器间通信时,朋友问起为什么非要配置路由选择协议。以前一般是根据配置手册或者经验配置也没有仔细考虑过这个问题。想了想,应该是这样理解的如下) 如果多个网段之间要实现通信,必需使用路由器,这个毫无疑问。如果多个网段之间请看如下
近日在机房讨论组网问题,当讨论到路由器间通信时,朋友问起为什么非要配置路由选择协议。以前一般是根据配置手册或者经验配置也没有仔细考虑过这个问题。想了想,应该是这样理解的如下)
如果多个网段之间要实现通信,必需使用路由器,这个毫无疑问。如果多个网段之间存在多个可选择的路径,最方便的采取配置路由选择协议的方法,简单点的网络可以采用RIP协议,如果是复杂的网络则可以采用OSPF当然在选择的路径不多时也可以采用静态路由的方法。
但是当多个网段之间只有一条路径时,那么仅仅是配置静态路由就足够了如果是企业中工作,那么往往配置简单的静态路由就足够了
为了更有说服力和便于理解我用CPTCiscoPacketTracer演示了一下。
拓扑图如下图所示:
分别有四个网段,10.0.0.0/8112.237.228.0/24192.168.10.0/24211.86.104.0/24
静态路由设置如下:
ip route 192.168.10.0 255.255.255.0 112.237.228.1
ip route 211.86.104.0 255.255.255.0 112.237.228.1
ip route 10.0.0.0 255.0.0.0 112.237.228.244
ip route 211.86.104.0 255.255.255.0 192.168.10.1
ip route 112.237.228.0 255.255.255.0 192.168.10.2
ip route 10.0.0.0 255.0.0.0 192.168.10.2
配置如下:
1.PC0IP配置:
PacketTracerPCCommandLine1.0
PC>ipconfig
IPAddress......................:10.0.0.3
SubnetMask.....................:255.0.0.0
DefaultGateway.................:10.0.0.1
PC>
2.PC1IP配置:
PacketTracerPCCommandLine1.0
PC>ipconfig
IPAddress......................:211.86.104.52
SubnetMask.....................:255.255.255.0
DefaultGateway.................:211.86.104.254
PC>
3.R1配置:
Router>enable
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z.
Routerconfig#hostname R1 R1config#interface FastEthernet0/1
R1config-if#ip address 10.0.0.1 255.0.0.0 R1config-if#no shutdown
%LINK-5-CHA NGED: Interface FastEthernet0/1, changed state to up R1config-if#end
R1# %SYS-5-CONFIG_I: Configured from console by consol
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z. R1config#int f0/0
R1config-if#ip addr 112.237.228.244 255.255.255.0 R1config-if#no shutdown
%LINK-5-CHA NGED: Interface FastEthernet0/0, changed state to up R1config-if#end
R1# %SYS-5-CONFIG_I: Configured from console by consol
R1#conf t Enter configuration commands, one per line. End with CNTL/Z.
R1config#ip route 192.168.10.0 255.255.255.0 112.237.228.1 R1config#ip route 211.86.104.0 255.255.255.0 112.237.228.1
R1config#end R1#
%SYS-5-CONFIG_I: Configured from console by consol
R1#
4.R2配置:
Router>enable
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z.
Routerconfig#hostname R2 R2config#
R2config#interface FastEthernet0/1 R2config-if#ip address 112.237.228.1 255.255.255.0
R2config-if#no shutdown
%LINK-5-CHA NGED: Interface FastEthernet0/1, changed state to up
R2config-if# R2config-if#exit
R2config#interface FastEthernet0/0 R2config-if#ip address 192.168.10.2 255.255.255.0
R2config-if#no shutdown
%LINK-5-CHA NGED: Interface FastEthernet0/0, changed state to up
R2config-if#end R2#conf t
Enter configuration commands, one per line. End with CNTL/Z. R2config#ip route 10.0.0.0 255.0.0.0 112.237.228.244
R2config#ip route 211.86.104.0 255.255.255.0 192.168.10.1 R2config#end
R2# %SYS-5-CONFIG_I: Configured from console by consol
R2#
5.R3配置:
Router>enable
Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z.
Routerconfig#hostname R3 R3config#
R3config#interface FastEthernet0/1 R3config-if#ip address 192.168.10.1 255.255.255.0
R3config-if#no shutdown
%LINK-5-CHA NGED: Interface FastEthernet0/1, changed state to up
R3config-if# R3config-if#exit
R3config#interface FastEthernet0/0 R3config-if#ip address 211.86.104.254 255.255.255.0
R3config-if#no shutdown
R3config-if# %LINK-5-CHA NGED: Interface FastEthernet0/0, changed state to up
R3>enable R3#conf t
Enter configuration commands, one per line. End with CNTL/Z. R3config#ip route 112.237.228.0 255.255.255.0 192.168.10.2
R3config#ip route 10.0.0.0 255.0.0.0 192.168.10.2 R3config#end
R3# %SYS-5-CONFIG_I: Configured from console by consol
R3#
6.使用tracert进行测试:
测试从PC0能否路由到PC1
结果标明测试胜利。
测试从PC1能否路由到PC0
结果标明测试胜利。
tags:192.168.1.1 路由器协议