1、2021/7/261(最新整理)华为eNSP配置实例6静态路由与默认路由2021/7/262 2专题6 静态路由与默认路由进阶配置2021/7/263 3场景场景你是你们公司的网络工程师,现在公司有一个总部和两个分支机构。其中R1为总部路由器,总部有一个网段,R2、R3为分支机构。R1通过串行线缆与分支机构相连,分支结构之间也通过串行线缆实现互联。因为网络规模较小,所以采用静态路由和默认路由的方式实现网络互通。IP地址编址信息如拓扑图。2021/7/264 4拓扑结构图10.0.23.1/2410.0.23.2/2410.0.2.2/2410.0.2.1/2410.0.12.2/2410.0.
2、12.1/2410.0.1.1/2410.0.1.2/2410.0.13.1/24 10.0.13.2/2410.0.3.2/2410.0.3.1/24每个接口(绿色小点)的IP地址标注在其旁边2021/7/265 5设置主机IP和网关主机的网关是其所连接的路由器端口的IP,如client0 连接路由器R1的E0/0/0端口(10.0.1.1),因此client0的网关是10.0.1.1,设置如下2021/7/266 61.R1的基础配置与IP编址undo ter monsystem-viewHuaweisysname R1R1int s0/0/1R1-Serial0/0/1ip addres
3、s 10.0.13.1 24R1-Serial0/0/1undo shutR1-Serial0/0/1int s0/0/0R1-Serial0/0/0ip address 10.0.12.1 24R1-Serial0/0/0undo shutR1-Serial0/0/0int e0/0/0R1-Ethernet0/0/0ip address 10.0.1.1 24R1-Ethernet0/0/0undo shutR1-Ethernet0/0/0quit2021/7/267 72.R2的基础配置与IP编址undo ter monsystem-viewHuaweisysname R2R2int s
4、0/0/1R2-Serial0/0/1ip address 10.0.12.2 24R2-Serial0/0/1undo shutR2-Serial0/0/1int s0/0/0R2-Serial0/0/0ip address 10.0.23.1 24R2-Serial0/0/0undo shutR2-Serial0/0/0int e0/0/0R2-Ethernet0/0/0ip address 10.0.2.1 24R2-Ethernet0/0/0undo shutR2-Ethernet0/0/0quit2021/7/268 83.R3的基础配置与IP编址undo ter monsystem
5、-viewHuaweisysname R3R3int s0/0/0R3-Serial0/0/0ip address 10.0.23.2 24R3-Serial0/0/0undo shutR3-Serial0/0/0interface s0/0/1R3-Serial0/0/1ip addr 10.0.13.2 24R3-Serial0/0/1undo shutR3-Serial0/0/1int e0/0/0R3-Ethernet0/0/0ip addr 10.0.3.1 24R3-Ethernet0/0/0undo shutR3-Ethernet0/0/0quit2021/7/269 94.测试
6、直连网络连通性在R1上ping 10.0.12.2 通ping 10.0.12.2 Reply from 10.0.12.2:bytes=56 Sequence=1 ttl=255 time=1 ms在R1上ping 10.0.13.2 通ping 10.0.13.2 Reply from 10.0.13.2:bytes=56 Sequence=1 ttl=255 time=1 ms2021/7/261010在R2上ping 10.0.12.1 通ping 10.0.12.1Reply from 10.0.12.1:bytes=56 Sequence=1 ttl=255 time=20 ms在
7、R2上ping 10.0.23.2 通ping 10.0.23.2Reply from 10.0.23.2:bytes=56 Sequence=1 ttl=255 time=60 ms2021/7/261111在R3上ping 10.0.23.1 通ping 10.0.23.1Reply from 10.0.23.1:bytes=56 Sequence=1 ttl=255 time=1 ms在R2上ping 10.0.13.1 通ping 10.0.13.1Reply from 10.0.23.2:bytes=56 Sequence=1 ttl=255 time=10 ms2021/7/261
8、2125 测试非直连网络的连通性测试非直连网络的连通性测试测试R2到目的网络到目的网络10.0.13.0/24、10.0.3.0/24的连通性的连通性ping 10.0.13.2 Request time out 不通ping 10.0.3.2 Request time out 不通此时R2如果要与网络10.0.3.0网段通讯,则需要R2上有去往该网段的路由信息,并且R3上也需要有回到R2接口IP网段的路由信息。以上测试结果显示R2无法与地址10.0.3.2和10.0.13.2地址通讯。2021/7/2613136 查看路由表 display ip routing-table Route Fl
9、ags:R-relay,D-download to fib-Routing Tables:Public Destinations:10 Routes:10 Destination/Mask Proto Pre Cost Flags NextHop Interface 10.0.2.0/24 Direct 0 0 D 10.0.2.1 Ethernet0/0/0 10.0.2.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0 10.0.12.0/24 Direct 0 0 D 10.0.12.2 Serial0/0/1 10.0.12.1/32 Direct 0
10、 0 D 10.0.12.1 Serial0/0/1 10.0.12.2/32 Direct 0 0 D 127.0.0.1 Serial0/0/1 10.0.23.0/24 Direct 0 0 D 10.0.23.1 Serial0/0/0 10.0.23.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/0 10.0.23.2/32 Direct 0 0 D 10.0.23.2 Serial0/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.
11、1 InLoopBack02021/7/261414发现R2的路由表里面没有去往10.0.1.0、10.0.3.0、10.0.13.0等网络的路由信息同理,你也可以发现在R1的路由表里面没有去往10.0.3.0、10.0.23.0、10.0.2.0等网络的路由信息同理,你也可以发现在R3的路由表里面没有去往10.0.1.0、10.0.12.0、10.0.2.0等网络的路由信息需要添加到这些网络的路由项目。2021/7/2615157.规划路由目的网络目的网络子网掩码子网掩码下一跳下一跳10.0.3.0255.255.255.010.0.13.210.0.23.0255.255.255.010.
12、0.12.210.0.2.0255.255.255.010.0.12.2R1的路由表目的网络目的网络子网掩码子网掩码下一跳下一跳10.0.1.0255.255.255.010.0.12.110.0.13.0255.255.255.010.0.23.210.0.3.0255.255.255.010.0.23.2R2的路由表目的网络目的网络子网掩码子网掩码下一跳下一跳10.0.1.0255.255.255.010.0.13.110.0.12.0255.255.255.010.0.23.110.0.2.0255.255.255.010.0.23.1R3的路由表2021/7/2616168.根据规划在
13、根据规划在R1 R2 R3上配置静态路由上配置静态路由 R1上增加三条 R1ip route-static 10.0.3.0 24 10.0.13.2R1ip route-static 10.0.23.0 24 10.0.12.2R1ip route-static 10.0.2.0 24 10.0.12.2R2上增加三条 R2ip route-static 10.0.3.0 24 10.0.23.2R2ip route-static 10.0.13.0 24 10.0.23.2R2ip route-static 10.0.1.0 24 10.0.12.1R3上增加三条 R3ip route-s
14、tatic 10.0.1.0 24 10.0.13.1R3ip route-static 10.0.12.0 24 10.0.23.1R3ip route-static 10.0.2.0 24 10.0.23.12021/7/2617179.查看路由表并测试连通性R1dis ip routing-tableRoute Flags:R-relay,D-download to fib-Routing Tables:Public Destinations:13 Routes:13 Destination/Mask Proto Pre Cost Flags NextHop Interface 10.0
15、.1.0/24 Direct 0 0 D 10.0.1.1 Ethernet0/0/0 10.0.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0 10.0.2.0/24 Static 60 0 RD 10.0.12.2 Serial0/0/0 10.0.3.0/24 Static 60 0 RD 10.0.13.2 Serial0/0/1 10.0.12.0/24 Direct 0 0 D 10.0.12.1 Serial0/0/0 10.0.12.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/0 10.0.12.2/32
16、Direct 0 0 D 10.0.12.2 Serial0/0/0 10.0.13.0/24 Direct 0 0 D 10.0.13.1 Serial0/0/1 10.0.13.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/1 10.0.13.2/32 Direct 0 0 D 10.0.13.2 Serial0/0/1 10.0.23.0/24 Static 60 0 RD 10.0.12.2 Serial0/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0
17、D 127.0.0.1 InLoopBack02021/7/261818在任意主机、路由器上互相ping都可以通过PCping 10.0.3.2Ping 10.0.3.2:32 data bytes,Press Ctrl_C to breakFrom 10.0.3.2:bytes=32 seq=3 ttl=126 time=47 msFrom 10.0.3.2:bytes=32 seq=4 ttl=126 time=46 msFrom 10.0.3.2:bytes=32 seq=5 ttl=126 time=16 msPCping 10.0.2.2Ping 10.0.2.2:32 data b
18、ytes,Press Ctrl_C to breakFrom 10.0.2.2:bytes=32 seq=1 ttl=126 time=109 msFrom 10.0.2.2:bytes=32 seq=2 ttl=126 time=46 ms2021/7/26191910 默认(缺省)路由观察R1的路由表10.0.2.0/24 Static 60 0 RD 10.0.12.2 Serial0/0/010.0.23.0/24 Static 60 0 RD 10.0.12.2 Serial0/0/0发现到达10.0.2.0和10.0.23.0这两个目的网络的路由具有相同的下一跳10.0.12.2可
19、以合并为一条缺省路由ip route-static 0.0.0.0 0.0.0.0 10.0.12.2 2021/7/262020首先需要把这两条路由删掉R1undo ip route-static 10.0.2.0 24 10.0.12.2R1undo ip route-static 10.0.23.0 24 10.0.12.22021/7/262121查看路由表发现已经没有了这两条R1dis ip routRoute Flags:R-relay,D-download to fib-Routing Tables:Public Destinations:11 Routes:11 Destina
20、tion/Mask Proto Pre Cost Flags NextHop Interface 10.0.1.0/24 Direct 0 0 D 10.0.1.1 Ethernet0/0/0 10.0.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0 10.0.3.0/24 Static 60 0 RD 10.0.13.2 Serial0/0/1 10.0.12.0/24 Direct 0 0 D 10.0.12.1 Serial0/0/0 10.0.12.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/0 10.0.12.2
21、/32 Direct 0 0 D 10.0.12.2 Serial0/0/0 10.0.13.0/24 Direct 0 0 D 10.0.13.1 Serial0/0/1 10.0.13.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/1 10.0.13.2/32 Direct 0 0 D 10.0.13.2 Serial0/0/1 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack02021/7/262222此时已经ping不通
22、这些地址了R1ping 10.0.2.2 PING 10.0.2.2:56 data bytes,press CTRL_C to break Request time out Request time out Request time out Request time out Request time out -10.0.2.2 ping statistics-5 packet(s)transmitted 0 packet(s)received 100.00%packet loss2021/7/262323增加上默认路由后重新可以通了R1ip route-static 0.0.0.0 0.0.0.0 10.0.12.2R1ping 10.0.2.2 PING 10.0.2.2:56 data bytes,press CTRL_C to breakReply from 10.0.2.2:bytes=56 Sequence=2 ttl=127 time=780 msReply from 10.0.2.2:bytes=56 Sequence=3 ttl=127 time=60 ms2021/7/262424