博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
直连路由和静态路由
阅读量:6259 次
发布时间:2019-06-22

本文共 16361 字,大约阅读时间需要 54 分钟。

                      直连路由和静态路由

                                        作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

一.简单直连路由拓扑

  上图中路由器不需要任何配置就能互相访问,因为这三个网段的网关地址都在同一个路由器的接口上,属于直连路由,路由器会自动生成路由表,不需要手动配置就可以让这三个区域互相ping通。这就是直连路由的作用!

 

二.静态路由

1.静态路由配置事实例

 

配置过程如下:

"深圳出口"配置如下:

1 [Huawei]sysname shenzhen 2 [R1]interface Ethernet 0/0/0 3 [R1-Ethernet0/0/0]IP address 192.168.1.254 20 4 [R1-Ethernet0/0/0]undo shutdown  5 [R1-Ethernet0/0/0]quit  6 [shenzhen]interface Ethernet 0/0/1 7 [shenzhen-Ethernet0/0/1]ip address 202.96.134.133 24 8 [shenzhen-Ethernet0/0/1]undo shutdown 9 [shenzhen-Ethernet0/0/1]quit 10 [shenzhen]ip route-static 0.0.0.0 0.0.0.0 202.96.134.134  #配置静态默认路由

"武汉骨干路由"配置如下:

1 [Huawei]sysname wuhan 2 [wuhan]interface Ethernet 0/0/1 3 [wuhan-Ethernet0/0/1]ip address 202.96.134.134 24 4 [wuhan-Ethernet0/0/1]undo shutdown 5 [wuhan-Ethernet0/0/1]quit  6 [wuhan]interface Ethernet 0/0/0 7 [wuhan-Ethernet0/0/0]ip address 202.103.24.68 24 8 [wuhan-Ethernet0/0/0]undo shutdown  9 [wuhan-Ethernet0/0/0]quit 10 [wuhan]ip route-static 192.168.0.0 20 202.96.134.13311 [wuhan]ip route-static 0.0.0.0 0.0.0.0 202.103.24.69

"石家庄骨干路由"配置如下:

1 [Huawei]sysname shijiazhuang 2 [shijiazhuang]interface Ethernet 0/0/0 3 [shijiazhuang-Ethernet0/0/0]ip address 202.103.24.69 24 4 [shijiazhuang-Ethernet0/0/0]undo shutdown  5 [shijiazhuang-Ethernet0/0/0]quit  6 [shijiazhuang]interface Ethernet 0/0/1 7 [shijiazhuang-Ethernet0/0/1]ip address 218.12.41.179 24 8 [shijiazhuang-Ethernet0/0/1]undo shutdown  9 [shijiazhuang-Ethernet0/0/1]quit 10 [shijiazhuang]ip route-static 172.30.0.0 21 218.12.41.180 #配置去往172.30.0.0/21的下一条静态路由11 [shijiazhuang]ip route-static 192.168.0.0 20 202.103.24.68

"北京出口"配置如下:

1 [Huawei]sysname beijing2 [beijing]interface Ethernet 0/0/03 [beijing-Ethernet0/0/0]ip address 172.30.3.254 214 [beijing-Ethernet0/0/0]undo shutdown 5 [beijing-Ethernet0/0/0]quit 6 [beijing]interface Ethernet 0/0/17 [beijing-Ethernet0/0/1]ip address 218.12.41.180 248 [beijing-Ethernet0/0/1]quit 9 [beijing]ip route-static 0.0.0.0 0.0.0.0 218.12.41.179

 深圳开发机测试结果如下:

1 PC>ipconfig  2   3 Link local IPv6 address...........: fe80::5689:98ff:fedc:58a6  4 IPv6 address......................: :: / 128  5 IPv6 gateway......................: ::  6 IPv4 address......................: 192.168.10.1  7 Subnet mask.......................: 255.255.240.0  8 Gateway...........................: 192.168.1.254  9 Physical address..................: 54-89-98-DC-58-A6 10 DNS server........................: 11  12 PC>ping 172.30.1.1 13  14 Ping 172.30.1.1: 32 data bytes, Press Ctrl_C to break 15 From 172.30.1.1: bytes=32 seq=1 ttl=124 time=109 ms 16 From 172.30.1.1: bytes=32 seq=2 ttl=124 time=140 ms 17 From 172.30.1.1: bytes=32 seq=3 ttl=124 time=109 ms 18 From 172.30.1.1: bytes=32 seq=4 ttl=124 time=125 ms 19 From 172.30.1.1: bytes=32 seq=5 ttl=124 time=109 ms 20  21 --- 172.30.1.1 ping statistics --- 22   5 packet(s) transmitted 23   5 packet(s) received 24   0.00% packet loss 25   round-trip min/avg/max = 109/118/140 ms 26  27 PC>ping 172.30.2.1 28  29 Ping 172.30.2.1: 32 data bytes, Press Ctrl_C to break 30 From 172.30.2.1: bytes=32 seq=1 ttl=124 time=124 ms 31 From 172.30.2.1: bytes=32 seq=2 ttl=124 time=109 ms 32 From 172.30.2.1: bytes=32 seq=3 ttl=124 time=94 ms 33 From 172.30.2.1: bytes=32 seq=4 ttl=124 time=171 ms 34 From 172.30.2.1: bytes=32 seq=5 ttl=124 time=124 ms 35  36 --- 172.30.2.1 ping statistics --- 37   5 packet(s) transmitted 38   5 packet(s) received 39   0.00% packet loss 40   round-trip min/avg/max = 94/124/171 ms 41  42 PC>ping 172.30.3.254 43  44 Ping 172.30.3.254: 32 data bytes, Press Ctrl_C to break 45 From 172.30.3.254: bytes=32 seq=1 ttl=252 time=94 ms 46 From 172.30.3.254: bytes=32 seq=2 ttl=252 time=93 ms 47 From 172.30.3.254: bytes=32 seq=3 ttl=252 time=63 ms 48 From 172.30.3.254: bytes=32 seq=4 ttl=252 time=94 ms 49 From 172.30.3.254: bytes=32 seq=5 ttl=252 time=94 ms 50  51 --- 172.30.3.254 ping statistics --- 52   5 packet(s) transmitted 53   5 packet(s) received 54   0.00% packet loss 55   round-trip min/avg/max = 63/87/94 ms 56  57 PC>ping 218.12.41.180 58  59 Ping 218.12.41.180: 32 data bytes, Press Ctrl_C to break 60 From 218.12.41.180: bytes=32 seq=1 ttl=252 time=109 ms 61 From 218.12.41.180: bytes=32 seq=2 ttl=252 time=93 ms 62 From 218.12.41.180: bytes=32 seq=3 ttl=252 time=93 ms 63 From 218.12.41.180: bytes=32 seq=4 ttl=252 time=78 ms 64 From 218.12.41.180: bytes=32 seq=5 ttl=252 time=78 ms 65  66 --- 218.12.41.180 ping statistics --- 67   5 packet(s) transmitted 68   5 packet(s) received 69   0.00% packet loss 70   round-trip min/avg/max = 78/90/109 ms 71  72 PC>ping 202.103.24.69 73  74 Ping 202.103.24.69: 32 data bytes, Press Ctrl_C to break 75 From 202.103.24.69: bytes=32 seq=1 ttl=253 time=62 ms 76 From 202.103.24.69: bytes=32 seq=2 ttl=253 time=78 ms 77 From 202.103.24.69: bytes=32 seq=3 ttl=253 time=94 ms 78 From 202.103.24.69: bytes=32 seq=4 ttl=253 time=62 ms 79 From 202.103.24.69: bytes=32 seq=5 ttl=253 time=63 ms 80  81 --- 202.103.24.69 ping statistics --- 82   5 packet(s) transmitted 83   5 packet(s) received 84   0.00% packet loss 85   round-trip min/avg/max = 62/71/94 ms 86  87 PC>ping 202.96.134.134 88  89 Ping 202.96.134.134: 32 data bytes, Press Ctrl_C to break 90 From 202.96.134.134: bytes=32 seq=1 ttl=254 time=47 ms 91 From 202.96.134.134: bytes=32 seq=2 ttl=254 time=63 ms 92 From 202.96.134.134: bytes=32 seq=3 ttl=254 time=62 ms 93 From 202.96.134.134: bytes=32 seq=4 ttl=254 time=62 ms 94 From 202.96.134.134: bytes=32 seq=5 ttl=254 time=46 ms 95  96 --- 202.96.134.134 ping statistics --- 97   5 packet(s) transmitted 98   5 packet(s) received 99   0.00% packet loss100   round-trip min/avg/max = 46/56/63 ms101 102 PC>ping 192.168.1.254103 104 Ping 192.168.1.254: 32 data bytes, Press Ctrl_C to break105 From 192.168.1.254: bytes=32 seq=1 ttl=255 time=16 ms106 From 192.168.1.254: bytes=32 seq=2 ttl=255 time=31 ms107 From 192.168.1.254: bytes=32 seq=3 ttl=255 time=31 ms108 From 192.168.1.254: bytes=32 seq=4 ttl=255 time=31 ms109 From 192.168.1.254: bytes=32 seq=5 ttl=255 time=32 ms110 111 --- 192.168.1.254 ping statistics ---112   5 packet(s) transmitted113   5 packet(s) received114   0.00% packet loss115   round-trip min/avg/max = 16/28/32 ms116 117 PC>
深圳开发机测试结果

 

2.静态路由实现路由备份和负载分担

a.路由备份:

  1>.到相同目的地址的下一条和优先级都不同;

  2>.优先级高的为主,低的为备;

b.负载分担:

  1>.到相同目的地址的下一跳不同,但优先级相同;

  2>.到目的地的流量均匀分布

案例展示:

  企业出口路由器是同事链接电信运营商和移动运营商,电信100M带宽,移动20M带宽,要求默认情况下企业内部上网全部走电信100M,当电信100M链路DOWN掉,自动切换到移动20M链路中去。

 

 案例分析:

    1.采用静态路由的备份技术(需要写2条默认路由,当一个ISP端口挂掉后,能够迅速自动启用另外的一个ISP出口。)

    2.默认情况下企业内部上网全部走电信;(需要这是默认路由的优先级);

 

配置过程如下:

"核心交换机"
1 "核心交换机"配置如下:2 [Huawei]sysname core3 [core]interface GigabitEthernet 0/0/104 [core-GigabitEthernet0/0/10]port link-type trunk
"公司路由"
1 "公司路由"配置如下: 2 [Huawei]sysname gongsi 3 [gongsi]interface Ethernet 0/0/0 4 [gongsi-Ethernet0/0/0]ip address 172.30.100.254 24 5 [gongsi-Ethernet0/0/0]undo shutdown  6 [gongsi-Ethernet0/0/0]quit  7 [gongsi]interface GigabitEthernet0/0/0 8 [gongsi-GigabitEthernet0/0/0]ip address 36.110.101.150 24 9 [gongsi-GigabitEthernet0/0/0]undo shutdown10 [gongsi-GigabitEthernet0/0/0]quit 11 [gongsi]interface GigabitEthernet 0/0/112 [gongsi-GigabitEthernet0/0/1]ip address 223.71.241.1 2413 [gongsi-GigabitEthernet0/0/1]undo shutdown 14 [gongsi-GigabitEthernet0/0/1]quit 15 [gongsi]ip route-static 0.0.0.0 0.0.0.0 36.110.101.15116 [gongsi]ip route-static 0.0.0.0 0.0.0.0 223.71.241.217 [gongsi]display ip routing-table18 Route Flags: R - relay, D - download to fib19 ------------------------------------------------------------------------------20 Routing Tables: Public21          Destinations : 9        Routes : 10       22 23 Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface24 25         0.0.0.0/0   Static  60   0          RD   36.110.101.151  GigabitEthernet0/0/0  #默认路由的优先级是都是60.26                     Static  60   0          RD   223.71.241.2    GigabitEthernet0/0/127    36.110.101.0/24  Direct  0    0           D   36.110.101.150  GigabitEthernet0/0/028  36.110.101.150/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/029       127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack030       127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack031    172.30.100.0/24  Direct  0    0           D   172.30.100.254  Ethernet0/0/032  172.30.100.254/32  Direct  0    0           D   127.0.0.1       Ethernet0/0/033    223.71.241.0/24  Direct  0    0           D   223.71.241.1    GigabitEthernet0/0/134    223.71.241.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/135 [gongsi]36 37 [gongsi]ip route-static 0.0.0.0 0.0.0.0 36.110.101.151 preference 50  #修改默认管理距离为50,默认的管理距离是60,这个数字越小,优先级就越高,越有限走这条路由!38 [gongsi]display ip routing-table 39 Route Flags: R - relay, D - download to fib40 ------------------------------------------------------------------------------41 Routing Tables: Public42          Destinations : 9        Routes : 9        43 44 Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface45 46         0.0.0.0/0   Static  50   0          RD   36.110.101.151  GigabitEthernet0/0/0  #进入路由表是管理距离小的,因为优先级比默认配置的60要小。47    36.110.101.0/24  Direct  0    0           D   36.110.101.150  GigabitEthernet0/0/048  36.110.101.150/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/049       127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack050       127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack051    172.30.100.0/24  Direct  0    0           D   172.30.100.254  Ethernet0/0/052  172.30.100.254/32  Direct  0    0           D   127.0.0.1       Ethernet0/0/053    223.71.241.0/24  Direct  0    0           D   223.71.241.1    GigabitEthernet0/0/154    223.71.241.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/155 [gongsi]
"电信ISP"
1 "电信ISP"配置如下: 2 [Huawei]sysname dianxin 3 [dianxin-GigabitEthernet0/0/1]ip address 36.110.101.151 24 4 [dianxin-GigabitEthernet0/0/1]undo shutdown  5 [dianxin-GigabitEthernet0/0/1]quit  6 [dianxin]interface LoopBack 1 7 [dianxin-LoopBack1]ip address 10.8.96.1 32 8 [dianxin-LoopBack1]quit  9 [dianxin]interface LoopBack 210 [dianxin-LoopBack2]ip address 10.8.96.2 3211 [dianxin-LoopBack2]quit 12 [dianxin]interface LoopBack 313 [dianxin-LoopBack3]ip address 10.8.96.3 3214 [dianxin-LoopBack3]quit 15 [dianxin]ip route-static 0.0.0.0 0.0.0.0 36.110.101.15016 
display ip routing-table17 Route Flags: R - relay, D - download to fib18 ------------------------------------------------------------------------------19 Routing Tables: Public20 Destinations : 8 Routes : 8 21 22 Destination/Mask Proto Pre Cost Flags NextHop Interface23 24 0.0.0.0/0 Static 60 0 RD 36.110.101.150 GigabitEthernet0/0/125 10.8.96.1/32 Direct 0 0 D 127.0.0.1 LoopBack126 10.8.96.2/32 Direct 0 0 D 127.0.0.1 LoopBack227 10.8.96.3/32 Direct 0 0 D 127.0.0.1 LoopBack328 36.110.101.0/24 Direct 0 0 D 36.110.101.151 GigabitEthernet0/0/129 36.110.101.151/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/130 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack031 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack032 33
"移动ISP"
1 "移动ISP"配置如下: 2 [Huawei]sysname yidong 3 [yidong]interface GigabitEthernet 0/0/2 4 [yidong-GigabitEthernet0/0/2]ip address 223.71.241.2 24 5 [yidong-GigabitEthernet0/0/2]undo shutdown  6 [yidong-GigabitEthernet0/0/2]quit 7 [yidong]interface LoopBack 1 8 [yidong-LoopBack1]ip address 10.8.96.1 32 9 [yidong-LoopBack1]quit 10 [yidong]interface LoopBack 211 [yidong-LoopBack2]ip address 10.8.96.2 3212 [yidong-LoopBack2]quit 13 [yidong]interface LoopBack 314 [yidong-LoopBack3]ip address 10.8.96.3 3215 [yidong-LoopBack3]quit16 [yidong]ip route-static 0.0.0.0 0.0.0.0 223.71.241.117 [yidong]display ip routing-table 18 Route Flags: R - relay, D - download to fib19 ------------------------------------------------------------------------------20 Routing Tables: Public21          Destinations : 8        Routes : 8        22 23 Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface24 25         0.0.0.0/0   Static  60   0          RD   223.71.241.1    GigabitEthernet0/0/226       10.8.96.1/32  Direct  0    0           D   127.0.0.1       LoopBack127       10.8.96.2/32  Direct  0    0           D   127.0.0.1       LoopBack228       10.8.96.3/32  Direct  0    0           D   127.0.0.1       LoopBack329       127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack030       127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack031    223.71.241.0/24  Direct  0    0           D   223.71.241.2    GigabitEthernet0/0/232    223.71.241.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/233 [yidong]

 测试结果如下:

1 PC>ipconfig 2  3 Link local IPv6 address...........: fe80::5689:98ff:fec4:4b82 4 IPv6 address......................: :: / 128 5 IPv6 gateway......................: :: 6 IPv4 address......................: 172.30.100.1 7 Subnet mask.......................: 255.255.255.0 8 Gateway...........................: 172.30.100.254 9 Physical address..................: 54-89-98-C4-4B-8210 DNS server........................:11 12 PC>ping 172.30.100.213 14 Ping 172.30.100.2: 32 data bytes, Press Ctrl_C to break15 From 172.30.100.2: bytes=32 seq=1 ttl=128 time=31 ms16 From 172.30.100.2: bytes=32 seq=2 ttl=128 time=15 ms17 From 172.30.100.2: bytes=32 seq=3 ttl=128 time=16 ms18 From 172.30.100.2: bytes=32 seq=4 ttl=128 time=16 ms19 From 172.30.100.2: bytes=32 seq=5 ttl=128 time=15 ms20 21 --- 172.30.100.2 ping statistics ---22   5 packet(s) transmitted23   5 packet(s) received24   0.00% packet loss25   round-trip min/avg/max = 15/18/31 ms26 27 PC>ping 172.30.100.25428 29 Ping 172.30.100.254: 32 data bytes, Press Ctrl_C to break30 From 172.30.100.254: bytes=32 seq=1 ttl=255 time=47 ms31 From 172.30.100.254: bytes=32 seq=2 ttl=255 time=31 ms32 From 172.30.100.254: bytes=32 seq=3 ttl=255 time=32 ms33 From 172.30.100.254: bytes=32 seq=4 ttl=255 time=32 ms34 From 172.30.100.254: bytes=32 seq=5 ttl=255 time=31 ms35 36 --- 172.30.100.254 ping statistics ---37   5 packet(s) transmitted38   5 packet(s) received39   0.00% packet loss40   round-trip min/avg/max = 31/34/47 ms41 42 PC>ping 36.110.101.15143 44 Ping 36.110.101.151: 32 data bytes, Press Ctrl_C to break45 From 36.110.101.151: bytes=32 seq=1 ttl=254 time=63 ms46 From 36.110.101.151: bytes=32 seq=2 ttl=254 time=47 ms47 From 36.110.101.151: bytes=32 seq=3 ttl=254 time=47 ms48 From 36.110.101.151: bytes=32 seq=4 ttl=254 time=46 ms49 From 36.110.101.151: bytes=32 seq=5 ttl=254 time=47 ms50 51 --- 36.110.101.151 ping statistics ---52   5 packet(s) transmitted53   5 packet(s) received54   0.00% packet loss55   round-trip min/avg/max = 46/50/63 ms56 57 PC>ping 223.71.241.258 59 Ping 223.71.241.2: 32 data bytes, Press Ctrl_C to break60 From 223.71.241.2: bytes=32 seq=1 ttl=254 time=47 ms61 From 223.71.241.2: bytes=32 seq=2 ttl=254 time=63 ms62 From 223.71.241.2: bytes=32 seq=3 ttl=254 time=47 ms63 From 223.71.241.2: bytes=32 seq=4 ttl=254 time=63 ms64 From 223.71.241.2: bytes=32 seq=5 ttl=254 time=62 ms65 66 --- 223.71.241.2 ping statistics ---67   5 packet(s) transmitted68   5 packet(s) received69   0.00% packet loss70   round-trip min/avg/max = 47/56/63 ms71 72 PC>ping 10.8.96.173 74 Ping 10.8.96.1: 32 data bytes, Press Ctrl_C to break75 From 10.8.96.1: bytes=32 seq=1 ttl=254 time=47 ms76 From 10.8.96.1: bytes=32 seq=2 ttl=254 time=78 ms77 From 10.8.96.1: bytes=32 seq=3 ttl=254 time=47 ms78 From 10.8.96.1: bytes=32 seq=4 ttl=254 time=47 ms79 From 10.8.96.1: bytes=32 seq=5 ttl=254 time=78 ms80 81 --- 10.8.96.1 ping statistics ---82   5 packet(s) transmitted83   5 packet(s) received84   0.00% packet loss85   round-trip min/avg/max = 47/59/78 ms86 87 PC>

 3.静态黑洞路由应用

正确应用黑洞路由可以消除环路

  通过上图中的静态路由的配置,RTA,RTB,RTC要是想访问RTE,则必须经过RTD,因为他们都是RTD的直连路由,因此当RTA访问RTE的数据时,RTD需要写一个默认路由扔个RTE,路由要有去有会,因此RTE会写一套静态路由扔个RTD,来回反复的扔来扔去就会导致环路,这个时候我们只需要在RTD中写一个静态路由,将RTE丢回来的数据放回回收站中不作处理即可。就不会导致环路发生。但是这么配置很是麻烦,你觉得呢?一两台路由器还好,要是多了,就比较没法了,静态路由配置比较繁琐,但是是路由中最有意思的,也能加强我们队路由的理解。后期,我们会学习RIP以及OSPF路由协议。

你可能感兴趣的文章
卢松松:每个网站都该有个监测服务
查看>>
Memcache与MySQL并肩作战
查看>>
使用Android模拟器测试Linux驱动(1)
查看>>
验证码广告:站长增加收入新渠道
查看>>
objective-c 枚举王国遍历数组
查看>>
C# WinForm开发系列 - OWC
查看>>
关于利用VS2008创建项目遇到的小困惑备忘
查看>>
发布一款域名监控小工具——Domain(IP)Watcher
查看>>
VBS中数组的各种处理方式
查看>>
通用数据权限管理系统设计
查看>>
High Resolution Timer in Java 5
查看>>
Visio2010绘制上下文数据流图
查看>>
SQL高级---SQL TOP 子句
查看>>
EhCache 分布式缓存/缓存集群
查看>>
[读书笔记]黑客与画家-思维、财富、创业、产品、设计、编程
查看>>
ecshop index.php源代码分析
查看>>
POJ 2057 The Lost House (经典树形dp)
查看>>
C#与Java的比较(转)
查看>>
jquery checkbox
查看>>
GNU make manual 翻译(三十二)
查看>>