静态路由也能胜任多网段之间进行通信

简介:
原创作品,允许转载,转载时请务必以超链接形式标明文章  原始出处 、作者信息和本声明。否则将追究法律责任。 http://dgd2010.blog.51cto.com/1539422/881922

昨天,和朋友在机房讨论组网问题,当讨论到路由器间通信时,朋友问起为什么非要配置路由选择协议。以前一般是根据配置手册或者经验配置也没有仔细考虑过这个问题。想了想,应该是这样理解的(如下)。

如果多个网段之间要实现通信,必须使用路由器,这个毫无疑问。如果多个网段之间存在多个可选择的路径,最方便的是采取配置路由选择协议的方法,简单点的网络可以采用RIP协议,如果是复杂的网络则可以采用OSPF。当然在选择的路径不多时也可以采用静态路由的方法。

但是,当多个网段之间只有一条路径时,那么仅仅是配置静态路由就足够了。如果是在企业中工作,那么往往配置简单的静态路由就足够了。

为了更有说服力和便于理解我用CPT(Cisco Packet Tracer)演示了一下。

拓扑图如下图所示:

P_Static_route-0

分别有四个网段,10.0.0.0/8、112.237.228.0/24、192.168.10.0/24、211.86.104.0/24。

静态路由设置如下:

 
 
  1. ip route 192.168.10.0 255.255.255.0 112.237.228.1   
  2. ip route 211.86.104.0 255.255.255.0 112.237.228.1  
  3.  
  4.  
  5. ip route 10.0.0.0 255.0.0.0 112.237.228.244   
  6. ip route 211.86.104.0 255.255.255.0 192.168.10.1  
  7.  
  8.  
  9. ip route 112.237.228.0 255.255.255.0 192.168.10.2   
  10. ip route 10.0.0.0 255.0.0.0 192.168.10.2   

配置如下:

1.PC0的IP配置:

Packet Tracer PC Command Line 1.0 
PC>ipconfig

IP Address......................: 10.0.0.3 
Subnet Mask.....................: 255.0.0.0 
Default Gateway.................: 10.0.0.1

PC>

2.PC1的IP配置:

Packet Tracer PC Command Line 1.0 
PC>ipconfig

IP Address......................: 211.86.104.52 
Subnet Mask.....................: 255.255.255.0 
Default Gateway.................: 211.86.104.254

PC>

3.R1的配置:

 
 
  1. Router>enable   
  2. Router#configure terminal   
  3. Enter configuration commands, one per line.  End with CNTL/Z.   
  4. Router(config)#hostname R1   
  5. R1(config)#interface FastEthernet0/1   
  6. R1(config-if)#ip address 10.0.0.1 255.0.0.0   
  7. R1(config-if)#no shutdown  
  8.  
  9.  
  10. %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up   
  11. R1(config-if)#end   
  12. R1#   
  13. %SYS-5-CONFIG_I: Configured from console by console  
  14.  
  15. R1#conf t   
  16. Enter configuration commands, one per line.  End with CNTL/Z.   
  17. R1(config)#int f0/0   
  18. R1(config-if)#ip addr 112.237.228.244 255.255.255.0   
  19. R1(config-if)#no shutdown  
  20.  
  21.  
  22. %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up   
  23. R1(config-if)#end   
  24. R1#   
  25. %SYS-5-CONFIG_I: Configured from console by console  
  26.  
  27.  
  28. R1#conf t   
  29. Enter configuration commands, one per line.  End with CNTL/Z.   
  30. R1(config)#ip route 192.168.10.0 255.255.255.0 112.237.228.1   
  31. R1(config)#ip route 211.86.104.0 255.255.255.0 112.237.228.1   
  32. R1(config)#end   
  33. R1#   
  34. %SYS-5-CONFIG_I: Configured from console by console  
  35.  
  36. R1# 

4.R2的配置:

 
 
  1. Router>enable   
  2. Router#configure terminal   
  3. Enter configuration commands, one per line.  End with CNTL/Z.   
  4. Router(config)#hostname R2   
  5. R2(config)#   
  6. R2(config)#interface FastEthernet0/1   
  7. R2(config-if)#ip address 112.237.228.1 255.255.255.0   
  8. R2(config-if)#no shutdown  
  9.  
  10.  
  11. %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up   
  12. R2(config-if)#   
  13. R2(config-if)#exit   
  14. R2(config)#interface FastEthernet0/0   
  15. R2(config-if)#ip address 192.168.10.2 255.255.255.0   
  16. R2(config-if)#no shutdown  
  17.  
  18.  
  19. %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up   
  20. R2(config-if)#end   
  21. R2#conf t   
  22. Enter configuration commands, one per line.  End with CNTL/Z.   
  23. R2(config)#ip route 10.0.0.0 255.0.0.0 112.237.228.244   
  24. R2(config)#ip route 211.86.104.0 255.255.255.0 192.168.10.1   
  25. R2(config)#end   
  26. R2#   
  27. %SYS-5-CONFIG_I: Configured from console by console  
  28.  
  29. R2#  

5.R3的配置: 

 
 
  1. Router>enable   
  2. Router#configure terminal   
  3. Enter configuration commands, one per line.  End with CNTL/Z.   
  4. Router(config)#hostname R3   
  5. R3(config)#   
  6. R3(config)#interface FastEthernet0/1   
  7. R3(config-if)#ip address 192.168.10.1 255.255.255.0   
  8. R3(config-if)#no shutdown  
  9.  
  10.  
  11. %LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up   
  12. R3(config-if)#   
  13. R3(config-if)#exit   
  14. R3(config)#interface FastEthernet0/0   
  15. R3(config-if)#ip address 211.86.104.254 255.255.255.0   
  16. R3(config-if)#no shutdown  
  17.  
  18. R3(config-if)#   
  19. %LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up  
  20.  
  21.  
  22. R3>enable   
  23. R3#conf t   
  24. Enter configuration commands, one per line.  End with CNTL/Z.   
  25. R3(config)#ip route 112.237.228.0 255.255.255.0 192.168.10.2   
  26. R3(config)#ip route 10.0.0.0 255.0.0.0 192.168.10.2      
  27. R3(config)#end   
  28. R3#   
  29. %SYS-5-CONFIG_I: Configured from console by console  
  30.  
  31. R3#  
  32.  

6.使用tracert进行测试:

测试从PC0能否路由到PC1。

image

结果表明测试成功。

测试从PC1能否路由到PC0。

image

结果表明测试成功。

本文出自 “通信,我的最爱” 博客,请务必保留此出处http://dgd2010.blog.51cto.com/1539422/881922

目录
相关文章
|
7月前
|
网络协议 网络虚拟化
数据通信网络之IPv6以太网单臂路由
数据通信网络之IPv6以太网单臂路由
59 1
|
7月前
|
网络架构
交换机与路由器技术-20-动态路由协议
交换机与路由器技术-20-动态路由协议
28 0
|
7月前
|
网络架构
交换机与路由器技术-17-生成树协议配置
交换机与路由器技术-17-生成树协议配置
30 0
|
7月前
|
网络架构
交换机与路由器技术-29-OSPF虚链路
交换机与路由器技术-29-OSPF虚链路
25 0
|
7月前
|
网络架构
交换机与路由器技术-12-单臂路由
交换机与路由器技术-12-单臂路由
38 0
|
11月前
|
网络协议 网络虚拟化 网络架构
单臂路由实现VLAN间相互通信
单臂路由实现VLAN间相互通信
131 0
|
11月前
|
监控 网络虚拟化
三层交换机实现VLAN间路由通信
三层交换机实现VLAN间路由通信
107 2
|
网络虚拟化 网络架构
ensp 实现三层交换机和单臂路由之间的通信
ensp 实现三层交换机和单臂路由之间的通信
167 0
ensp 实现三层交换机和单臂路由之间的通信