一、目的
· 2、 掌握测试静态路由连通性的方法
· 3、 掌握通过配置缺省路由实现本地网络与外部网络间的访问
· 4、 掌握静态备份路由的配置方法
二、拓扑
中R1为总部路由器,R2、R3为分支机构,总部与分支机构间通过以太网实现互连,且当前公司网络中没有配置任何路由协议。
三、步骤
1、 基础配置和IP地址
在R1、R2和R3上配置设备名称和IP地址。
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.0.13.1 24
[R1-GigabitEthernet0/0/0]quit
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.0.12.1 24
[R1-GigabitEthernet0/0/1]quit
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 10.0.1.1 24
执行display current-configuration命令,检查配置情况。
display ip interface brief
Interface IP Address/Mask Physical Protocol
……output omit……
GigabitEthernet0/0/0 10.0.13.1/24 up up
GigabitEthernet0/0/1 10.0.12.1/24 up up
GigabitEthernet0/0/2 unassigned up down
LoopBack0 10.0.1.1/24 up up(s)
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 10.0.12.2 24
[R2-GigabitEthernet0/0/1]quit
[R2]interface GigabitEthernet0/0/2
[R2-GigabitEthernet0/0/2]ip add 10.0.23.2 24
[R2-GigabitEthernet0/0/2]quit
[R2]interface LoopBack0
[R2-LoopBack0]ip address 10.0.2.2 24
display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned up down
GigabitEthernet0/0/1 10.0.12.2/24 up up
GigabitEthernet0/0/2 10.0.23.2/24 up up
LoopBack0 10.0.2.2/24 up up(s)
system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 10.0.13.3 24
[R3-GigabitEthernet0/0/0]quit
[R3]interface GigabitEthernet0/0/2
[R3-GigabitEthernet0/0/2]ip address 10.0.23.3 24
[R3-GigabitEthernet0/0/2]quit
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 10.0.3.3 24
display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 10.0.13.3/24 up up
GigabitEthernet0/0/1 unassigned up down
GigabitEthernet0/0/2 10.0.23.3/24 up up
LoopBack0 10.0.3.3/24 up up(s)
2、执行ping命令,检测R1与其它设备间的连通性。
ping 10.0.12.2
PING 10.0.12.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 10.0.12.2: bytes=56 Sequence=2 ttl=255 time=30 ms
ping 10.0.13.3
PING 10.0.13.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.13.3: bytes=56 Sequence=1 ttl=255 time=6 ms
Reply from 10.0.13.3: bytes=56 Sequence=2 ttl=255 time=2 ms
执行ping命令,检测R2与其它设备间的连通性。
ping 10.0.23.3
PING 10.0.23.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.23.3: bytes=56 Sequence=1 ttl=255 time=31 ms
Reply from 10.0.23.3: bytes=56 Sequence=2 ttl=255 time=31 ms
3、 测试R2到目的网络10.0.13.0/24、10.0.3.0/24的连通性
ping 10.0.13.3
PING 10.0.13.3: 56 data bytes, press CTRL_C to break
Request time out
Request time out
ping 10.0.3.3
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Request time out
Request time out
R2不能与10.0.3.3和10.0.13.3网络通信。需要有路由到达目的地址
display ip routing-table
Route Flags: R – relay, D – download to fib
————————————————————————-
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.0/24 Direct 0 0 D 10.0.2.2 LoopBack0
10.0.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.0.2.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
4、在R2上配置静态路由
配置目的地址为10.0.13.0/24和10.0.3.0/24的静态路由,路由的下一跳配置为R3的G0/0/0接口IP地址10.0.23.3。华为默认静态路由优先级为60
[R2]ip route-static 10.0.13.0 24 10.0.23.3
[R2]ip route-static 10.0.3.0 24 10.0.23.3
display ip routing-table
Route Flags: R – relay, D – download to fib
——————————————————————————
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.0/24 Direct 0 0 D 10.0.2.2 LoopBack0
10.0.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.0.2.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.0.3.0/24 Static 60 0 RD 10.0.23.3 GigabitEthernet0/0/2
10.0.13.0/24 Static 60 0 RD 10.0.23.3 GigabitEthernet0/0/2
5、配置备份静态路由
R2与网络10.0.13.3和10.0.3.3之间交互的数据通过R2与R3间的链路传输。如果R2和R3间的链路发生故障,R2将不能与网络10.0.13.3和10.0.3.3通信。
但是根据拓扑图可以看出,当R2和R3间的链路发生故障时,R2还可以通过R1与R3通信。所以可以通过配置一条备份静态路由实现路由的冗余备份。正常情况下,备份静态路由不生效。当R2和R3间的链路发生故障时,才使用备份静态路由传输数据。
配置备份静态路由时,需要修改备份静态路由的优先级,确保只有主链路故障时才使用备份路由。本任务中,需要将备份静态路由的优先级修改为80。
[R1]ip route-static 10.0.3.0 24 10.0.13.3
[R2]ip route-static 10.0.13.0 255.255.255.0 10.0.12.1 preference 80
[R2]ip route-static 10.0.3.0 24 10.0.12.1 preference 80
[R3]ip route-static 10.0.12.0 24 10.0.13.1
6、验证路由
在R2的路由表中,查看当前的静态路由配置。
display ip routing-table
Route Flags: R – relay, D – download to fib
————————————————————————-
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.0/24 Direct 0 0 D 10.0.2.2 LoopBack0
10.0.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.0.2.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.0.3.0/24 Static 60 0 RD 10.0.23.3 GigabitEthernet0/0/2
10.0.12.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
10.0.13.0/24 Static 60 0 RD 10.0.23.3 GigabitEthernet0/0/2
10.0.23.0/24 Direct 0 0 D 10.0.23.2 GigabitEthernet0/0/2
路由表中包含两条静态路由。其中,Protocol字段的值是Static,表明该路由是静态路由。Preference字段的值是60,表明该路由使用的是默认优先级。
当R2和R3之间链路正常时,R2与网络10.0.13.3和10.0.3.3之间交互的数据通过R2与R3间的链路传输。执行tracert命令,可以查看数据的传输路径。
tracert 10.0.13.3
traceroute to 10.0.13.3(10.0.13.3), max hops: 30 ,packet length: 40,
press CTRL_C to break
1 10.0.23.3 40 ms 31 ms 30 ms
tracert 10.0.3.3
traceroute to 10.0.3.3(10.0.3.3), max hops: 30 ,packet length: 40,
press CTRL_C to break
1 10.0.23.3 40 ms 30 ms 30 ms
命令的回显信息证实R2将数据直接发送给R3,未经过其他设备。
如果喜欢这段内容,欢迎大家点赞、收藏、分享、转发。欢迎网络技术爱好者加入网络狂热爱好者圈子交流,圈内持续更新分享【干货】网络技术,坚持下去你会发现有意外的成长和收获!
(此处已添加圈子卡片,请到今日头条客户端查看)
新出炉适合零基础入门的网络技术视频欢迎大家学习!持续更新!【华为网络为主+思科网络辅助】