实验八 静态路由
实验目的:
- 理解路由器的工作原理
- 理解静态路由
- 掌握静态路由的配置
实验拓扑
计算机IP地址及网关地址:
PC1:192.168.1.1/24 GW:192.168.1.254
PC2:192.168.2.1/24 GW:192.168.2.254
路由器AR1接口的IP地址:
G0/0/0:192.168.1.254/24
G0/0/1:192.168.3.1/24
路由器AR2接口的IP地址:
G0/0/0:192.168.2.254/24
G0/0/1:192.168.3.2/4
实验步骤
一、配置各计算机的IP地址
1.PC1的IP地址配置
2.PC2的IP地址配置
二、配置路由器各接口地址并开启接口
1.配置AR1的接口地址并开启接口
点击查看代码
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR1
[AR1]inte g0/0/0
[AR1-GigabitEthernet0/0/0]ip address 192.168.1.254 24
Apr 6 2023 21:49:48-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[AR1-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[AR1-GigabitEthernet0/0/0]
[AR1-GigabitEthernet0/0/0]quit
[AR1]
[AR1]
[AR1]interface g0/0/1
[AR1-GigabitEthernet0/0/1]ip address 192.168.3.1 24
[AR1-GigabitEthernet0/0/1]
Apr 6 2023 21:51:56-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[AR1-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[AR1-GigabitEthernet0/0/1]
2.配置AR2的接口地址并开启接口
点击查看代码
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]inte g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.169.2.254 24
[Huawei-GigabitEthernet0/0/0]
Apr 6 2023 21:54:15-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[Huawei-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Huawei-GigabitEthernet0/0/0]inte g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.3.2 24
Apr 6 2023 21:54:37-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol
IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[Huawei-GigabitEthernet0/0/1]ip address 192.168.3.2 24
Error: The address already exists.
[Huawei-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[Huawei-GigabitEthernet0/0/1]
三、测试两台计算机的连通性
从PC1通过ping命令测试与PC2的连通性
点击查看代码
Welcome to use PC Simulator!
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe9b:3c7f
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.1
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.254
Physical address..................: 54-89-98-9B-3C-7F
DNS server........................:
PC>ping 192.168.2.1
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PC>
通过以上结果,可以看出PC1到PC2是不能连通的。
接下来,测试与网关的连通性,即192.168.1.254IP地址对应的接口G0/0/0的连通性。
点击查看代码
PC>ping 192.168.1.254
Ping 192.168.1.254: 32 data bytes, Press Ctrl_C to break
From 192.168.1.254: bytes=32 seq=1 ttl=255 time=78 ms
From 192.168.1.254: bytes=32 seq=2 ttl=255 time=47 ms
From 192.168.1.254: bytes=32 seq=3 ttl=255 time=16 ms
From 192.168.1.254: bytes=32 seq=4 ttl=255 time=15 ms
From 192.168.1.254: bytes=32 seq=5 ttl=255 time=16 ms
--- 192.168.1.254 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 15/34/78 ms
PC>
四、在两台路由器上配置静态路由
1.查看AR1的静态路由
点击查看代码
[AR1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
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 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet
0/0/0
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.3.0/24 Direct 0 0 D 192.168.3.1 GigabitEthernet
0/0/1
192.168.3.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.3.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[AR1]
通过以上结果发现只有到192.168.1.0和192.168.3.0网段的路由信息,而这两个路由是直连路由。
2.配置AR1的静态路由
在本实验中,共有三个IP子网,分别是192.168.1.0、192.168.2.0、192.168.3.0,与AR1非直连的只有192.168.2.0,所以在AR1上只需要配置到达192.168.2.0的路由即可,到达该网段的路由需要通过AR1的G0/0/1端口进行转发,所以配置的下一跳地址是与该接口直接相连的对端路由器AR2的G0/0/1接口的IP地址。
[AR1]ip route-static 192.168.2.0 24 192.168.3.2
3.配置AR2的静态路由
同理,配置AR2的静态路由,在该路由器的配置中,使用的接口对端的IP地址的模式。
[Huawei]ip route-static 192.168.1.0 24 192.168.3.1