实验
设置各路由器与交换机名称(每次修改参数都需使用save命令保存)
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname S1 [S1] # ctrl+z 退出,并保存 <S1>save
-
建立实验拓扑
路由器实验拓扑如上,S1.S2选择S5700,R1选择AR1200,连线为copper,连接到设备时选择GE或Ethernet接口
设备 接口 IP地址 子网掩码 默认网关 PC1 Ethernet0/0/1 10.0.1.1 255.255.255.0 10.0.1.254 PC2 Ethernet0/0/1 10.0.2.1 255.255.255.0 10.0.2.254 R1 GE 0/0/0 10.0.1.254 255.255.255.0 N/A GE 0/0/1 10.0.2.254 255.255.255.0 N/A -
基础配置
设置两台PC的IP地址和子网掩码
-
配置路由器接口IP地址
双击进入路由器系统视图进行配置
<Huawei>system-view Enter system view, return user view with Ctrl+Z. # 进入GE0/0/0接口视图 [Huawei]interface GigabitEthernetb 0/0/0 # 配置IP地址和掩码 [Huawei-GigabitEthernet0/0/0]ip add 10.0.1.254 24 Mar 16 2023 08:42:10-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. # 同样方法进入GE0/0/1接口的配置 [Huawei-GigabitEthernet0/0/0]int G0/0/1 [Huawei-GigabitEthernet0/0/1]ip add 10.0.2.254 24 # 配置完成,查看接口与IP相关信息 [Huawei]display ip interface brief *down: administratively down ^down: standby (l): loopback (s): spoofing The number of interface that is UP in Physical is 3 The number of interface that is DOWN in Physical is 0 The number of interface that is UP in Protocol is 3 The number of interface that is DOWN in Protocol is 0 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 10.0.1.254/24 up up GigabitEthernet0/0/1 10.0.2.254/24 up up NULL0 unassigned up up(s) # 配置完成要进行保存(ctrl+z退出) <Huawei>save The current configuration will be written to the device. Are you sure to continue? (y/n)[n]:y It will take several minutes to save configuration file, please wait........
-
查看路由器配置信息
display ip routing-table
:查看ipv4路由表信息 -
测试连通性
直连网段连通性测试完毕后,再测试非直连设备(PC)能否ping通
# 路由器ping <Huawei>ping 10.0.1.1 PING 10.0.1.1: 56 data bytes, press CTRL_C to break Reply from 10.0.1.1: bytes=56 Sequence=1 ttl=128 time=100 ms Reply from 10.0.1.1: bytes=56 Sequence=2 ttl=128 time=70 ms Reply from 10.0.1.1: bytes=56 Sequence=3 ttl=128 time=60 ms Reply from 10.0.1.1: bytes=56 Sequence=4 ttl=128 time=40 ms Reply from 10.0.1.1: bytes=56 Sequence=5 ttl=128 time=40 ms --- 10.0.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 40/62/100 ms <Huawei>ping 10.0.2.1 PING 10.0.2.1: 56 data bytes, press CTRL_C to break Reply from 10.0.2.1: bytes=56 Sequence=1 ttl=128 time=40 ms --- 10.0.2.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 30/42/60 ms # 通过PC1和PC2命令行来测试其连通性 PC>ping 10.0.2.1 Ping 10.0.2.1: 32 data bytes, Press Ctrl_C to break From 10.0.2.1: bytes=32 seq=1 ttl=127 time=78 ms From 10.0.2.1: bytes=32 seq=2 ttl=127 time=78 ms From 10.0.2.1: bytes=32 seq=3 ttl=127 time=47 ms From 10.0.2.1: bytes=32 seq=4 ttl=127 time=62 ms From 10.0.2.1: bytes=32 seq=5 ttl=127 time=47 ms --- 10.0.2.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 47/62/78 ms