免费注册 查看新帖 |

Chinaunix

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

静态路由 [复制链接]

论坛徽章:
2
IT运维版块每日发帖之星
日期:2016-03-29 06:20:00IT运维版块每日发帖之星
日期:2016-03-30 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-03-27 17:19 |只看该作者 |倒序浏览
本帖最后由 anonym0us 于 2016-03-27 17:23 编辑

  1. 静态路由:


  2. 首先配置R1 R2 R3的基本配置,为相应的接口配置合理的IP 地址。同一根网线上连接的两个路由器,要配置相同的网络位,不同的主机位因为他们是位于同一个网络的不同设备。
  3. R1配置:

  4. Router>enable
  5. Router#configure terminal

  6. Router(config)#line console 0
  7. Router(config-line)#exec-timeout  0 0
  8. Router(config-line)#logging synchronous
  9. Router(config-line)#exit

  10. Router(config)#no ip domain-lookup
  11. Router(config)#ho R1



  12. R1(config)#interface loopback 0
  13. R1(config-if)#ip address 1.1.1.1 255.255.255.255
  14. R1(config-if)#no shutdown
  15. R1(config-if)#exit

  16. R1(config)#interface loopback 1
  17. R1(config-if)#ip address 1.1.2.1 255.255.255.255
  18. R1(config-if)#no shutdown
  19. R1(config-if)#exit

  20. R1(config)#interface loopback 2
  21. R1(config-if)#ip address 1.1.3.1 255.255.255.255
  22. R1(config-if)#no shutdown
  23. R1(config-if)#exit

  24. R1(config)#interface loopback 3
  25. R1(config-if)#ip address 1.1.4.1 255.255.255.255
  26. R1(config-if)#no shutdown
  27. R1(config-if)#exit

  28. R1(config)#interface f0/0
  29. R1(config-if)#ip address 12.1.1.1 255.255.255.0
  30. R1(config-if)#no shutdown
  31. R1(config-if)#exit

  32. R2配置:

  33. Router>enable
  34. Router#config terminal
  35. Router(config)#line console 0
  36. Router(config-line)#exec-timeout 0 0
  37. Router(config-line)#logging synchronous
  38. Router(config-line)#exit

  39. Router(config)#no ip domain-lookup
  40. Router(config)#ho R2

  41. R2(config)#interface f0/0
  42. R2(config-if)#ip address 12.1.1.2 255.255.255.0
  43. R2(config-if)#no shutdown
  44. R2(config-if)#exit



  45. R2(config)#interface f0/1
  46. R2(config-if)#ip address 23.1.1.2 255.255.255.0
  47. R2(config-if)#no shutdown
  48. R2(config-if)#exit

  49. R2(config)#interface loopback 0
  50. R2(config-if)#ip address 2.2.2.2 255.255.255.255
  51. R2(config-if)#no  shutdown
  52. R2(config-if)#exit

  53. R3配置:
  54. Router>enable
  55. Router#config terminal

  56. Router(config)#line console 0
  57. Router(config-line)#exec-timeout 0 0
  58. Router(config-line)#logging synchronous
  59. Router(config-line)#exit
  60. Router(config)#no ip domain-lookup

  61. Router(config)#ho R3

  62. R3(config)#interface f0/1
  63. R3(config-if)#ip address 23.1.1.3 255.255.255.0
  64. R3(config-if)#no shutdown
  65. R3(config-if)#exit

  66. R3(config)#interface lo0
  67. R3(config-if)#ip address 3.3.3.3 255.255.255.255
  68. R3(config-if)#no shutdown
  69. R3(config-if)#exit

  70. 接下来在R1 R2 R3上配置静态路由,由于一个路由器的接口配置了IP 地址之后,对于路由器而言,就产生了到达该网络的路径,就是我们所说的直连路径。因此我们仅仅需要配置到达网络中其他地方(非直连)网络的路径即可。

  71. R1配置:
  72. 对于R1而言直连路经就是路由表中打C 标记的路由,而2.2.2.2/32,3.3.3.3/32,23.1.1.0/24
  73. 这几条路径R1的路由表中没有(这些是非直连路径),因此需要针对这几条路径进行配置.

  74. R1#sho ip route
  75. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  76.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  77.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  78.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  79.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  80.        * - candidate default, U - per-user static route, o - ODR
  81.        P - periodic downloaded static route

  82. Gateway of last resort is not set

  83.      1.0.0.0/32 is subnetted, 4 subnets
  84. C       1.1.1.1 is directly connected, Loopback0
  85. C       1.1.2.1 is directly connected, Loopback1
  86. C       1.1.3.1 is directly connected, Loopback2
  87. C       1.1.4.1 is directly connected, Loopback3
  88.      12.0.0.0/24 is subnetted, 1 subnets
  89. C       12.1.1.0 is directly connected, FastEthernet0/0
  90. R1#
  91. 要去哪里----目标IP地址和掩码
  92. R1(config)#ip route 3.3.3.3 255.255.255.255 12.1.1.2               有谁帮我把数据转发到目的地---下一跳地址
  93. R1(config)#ip route 23.1.1.0 255.255.255.0 12.1.1.2
  94. R1(config)#ip route 2.2.2.2 255.255.255.255 f0/0                   要去那里,该从那个接口把数据发出去—出接口

  95. R2配置:
  96. 对于R2而言 只有 1.1.1.1-----1.1.2.1----1.1.3.1----1.1.4.1以及3.3.3.3 是不直接相连的(非直连),因此只需要针对这些网段写静态路由就可以了,对于1.1.1.1----1.1.4.1的这四条路径,可以用汇总的方式,以一条命令去完成对于四条命令的匹配.---进行汇总.同时注意,汇总的时候,有可能将1.1.5.1等等不存在的网段也汇总进去了,因此注意,在R1上(应为汇总的1.1.1.1—1.1.4.1 是R1上的路径)部署黑洞路由.

  97. R2(config)#ip route 1.1.0.0 255.255.248.0 12.1.1.1
  98. R2(config)#ip route 3.3.3.3 255.255.255.255 23.1.1.3

  99. R1配置:

  100. R1(config)#ip route 1.1.0.0 255.255.248.0 null 0


  101. R3配置:
  102. 在R3上 我们可以认为R3上网络的终点,因此对于R3而言,到网络的任意一点,都可以被缺省路由匹配.

  103. R3(config)#ip route 0.0.0.0 0.0.0.0 23.1.1.2

  104. 检查路由表,看看路径是否都齐全.
  105. R1 R2 R3要有到达 1.1.1.1—1.1.2.1---1.1.3.1---1.1.4.1以及12.1.1.0/24;23.1.1.0/24;
  106. 2.2.2.2/32;3.3.3.3/32的路径.

  107. R1配置:
  108. R1#sho ip route
  109. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  110.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  111.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  112.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  113.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  114.        * - candidate default, U - per-user static route, o - ODR
  115.        P - periodic downloaded static route

  116. Gateway of last resort is not set

  117.      1.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
  118. S       1.1.0.0/21 is directly connected, Null0
  119. C       1.1.1.1/32 is directly connected, Loopback0
  120. C       1.1.2.1/32 is directly connected, Loopback1
  121. C       1.1.3.1/32 is directly connected, Loopback2
  122. C       1.1.4.1/32 is directly connected, Loopback3
  123.      2.0.0.0/32 is subnetted, 1 subnets
  124. S       2.2.2.2 is directly connected, FastEthernet0/0
  125.      3.0.0.0/32 is subnetted, 1 subnets
  126. S       3.3.3.3 [1/0] via 12.1.1.2
  127.      12.0.0.0/24 is subnetted, 1 subnets
  128. C       12.1.1.0 is directly connected, FastEthernet0/0
  129.      23.0.0.0/24 is subnetted, 1 subnets
  130. S       23.1.1.0 [1/0] via 12.1.1.2

  131. R2配置:
  132. R2#sho ip route
  133. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  134.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  135.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  136.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  137.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  138.        * - candidate default, U - per-user static route, o - ODR
  139.        P - periodic downloaded static route

  140. Gateway of last resort is not set

  141.      1.0.0.0/21 is subnetted, 1 subnets
  142. S       1.1.0.0 [1/0] via 12.1.1.1
  143.      2.0.0.0/32 is subnetted, 1 subnets
  144. C       2.2.2.2 is directly connected, Loopback0
  145.      3.0.0.0/32 is subnetted, 1 subnets
  146. S       3.3.3.3 [1/0] via 23.1.1.3
  147.      12.0.0.0/24 is subnetted, 1 subnets
  148. C       12.1.1.0 is directly connected, FastEthernet0/0
  149.      23.0.0.0/24 is subnetted, 1 subnets
  150. C       23.1.1.0 is directly connected, FastEthernet0/1

  151. R3配置:
  152. R3#sho ip rou
  153. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
  154.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  155.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  156.        E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  157.        i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  158.        * - candidate default, U - per-user static route, o - ODR
  159.        P - periodic downloaded static route

  160. Gateway of last resort is 23.1.1.2 to network 0.0.0.0

  161.      3.0.0.0/32 is subnetted, 1 subnets
  162. C       3.3.3.3 is directly connected, Loopback0
  163.      23.0.0.0/24 is subnetted, 1 subnets
  164. C       23.1.1.0 is directly connected, FastEthernet0/1
  165. S*   0.0.0.0/0 [1/0] via 23.1.1.2
复制代码

论坛徽章:
3
IT运维版块每日发帖之星
日期:2015-08-09 06:20:00IT运维版块每周发帖之星
日期:2015-09-11 19:20:31IT运维版块每日发帖之星
日期:2016-04-04 06:20:00
2 [报告]
发表于 2016-04-01 14:28 |只看该作者
路过~~~~~·
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP