拓扑图
如下图,需要配置ospf协议让R1~R8这些设备全部ping通,路由器需配置环回接口。
配置
R3配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R3
//配置环回接口地址(先配置,RouterID就会默认是环回接口地址)
[R3]int loopback 0
[R3-LoopBack0]ip add 3.3.3.3 32
//配置其他端口地址
[R3-LoopBack0]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 10.1.1.1 24
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 10.1.2.1 24
//查看RouterID
[R3-GigabitEthernet0/0/1]dis router id
RouterID:3.3.3.3
//配置ospf
[R3-GigabitEthernet0/0/1]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
//退出保存配置
[R3-ospf-1-area-0.0.0.0]q
[R3-ospf-1]q
[R3]q
<R3>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
<R3>
R4配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R4
[R4]int loopback 0
[R4-LoopBack0]ip add 4.4.4.4 32
[R4-LoopBack0]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 10.1.4.2 24
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 10.1.1.2 24
[R4-GigabitEthernet0/0/1]dis router id
RouterID:4.4.4.4
[R4-GigabitEthernet0/0/1]ospf 1
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 10.1.4.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]q
[R4-ospf-1]q
[R4]q
<R4>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
R5配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R5
[R5]int loopback 0
[R5-LoopBack0]ip add 5.5.5.5 32
[R5-LoopBack0]int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 10.2.1.2 24
[R5-GigabitEthernet0/0/0]dis router id
RouterID:5.5.5.5
[R5-GigabitEthernet0/0/0]ospf 1
//注意这里的区域设置为2
[R5-ospf-1]area 2
[R5-ospf-1-area-0.0.0.2]network 10.2.1.0 0.0.0.255
[R5-ospf-1-area-0.0.0.2]q
[R5-ospf-1]q
[R5]q
<R5>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
R6配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R6
[R6]int loopback 0
[R6-LoopBack0]ip add 6.6.6.6 32
[R6-LoopBack0]int g0/0/0
[R6-GigabitEthernet0/0/0]ip add 10.2.2.2 24
[R6-GigabitEthernet0/0/0]dis router id
RouterID:6.6.6.6
[R6-GigabitEthernet0/0/0]ospf 1
[R6-ospf-1]area 2
[R6-ospf-1-area-0.0.0.2]network 10.2.2.0 0.0.0.255
[R6-ospf-1-area-0.0.0.2]q
[R6-ospf-1]q
[R6]q
<R6>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
R7配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R7
[R7]int loopback 0
[R7-LoopBack0]ip add 7.7.7.7 32
[R7-LoopBack0]int g0/0/0
[R7-GigabitEthernet0/0/0]ip add 10.3.1.2 24
[R7-GigabitEthernet0/0/0]dis router id
RouterID:7.7.7.7
[R7-GigabitEthernet0/0/0]ospf 1
//注意这里区域配置为1
[R7-ospf-1]area 1
[R7-ospf-1-area-0.0.0.1]network 10.3.1.0 0.0.0.255
[R7-ospf-1-area-0.0.0.1]q
[R7-ospf-1]q
[R7]q
<R7>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
R8配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R8
[R8]int loopback 0
[R8-LoopBack0]ip add 8.8.8.8 32
[R8-LoopBack0]int g0/0/0
[R8-GigabitEthernet0/0/0]ip add 10.3.2.2 24
[R8-GigabitEthernet0/0/0]dis router id
RouterID:8.8.8.8
[R8-GigabitEthernet0/0/0]ospf 1
[R8-ospf-1]area 1
[R8-ospf-1-area-0.0.0.1]network 10.3.2.0 0.0.0.255
[R8-ospf-1-area-0.0.0.1]q
[R8-ospf-1]q
[R8]q
<R8>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
R1配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R1
[R1]int loopback 0
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 10.1.3.1 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 10.1.2.2 24
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add 10.2.1.1 24
[R1-GigabitEthernet0/0/2]int g0/0/3
[R1-GigabitEthernet0/0/3]ip add 10.2.2.1 24
[R1-GigabitEthernet0/0/3]dis router id
RouterID:1.1.1.1
[R1-GigabitEthernet0/0/3]ospf 1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 10.1.3.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]area 2
[R1-ospf-1-area-0.0.0.2]network 10.2.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.2]network 10.2.2.0 0.0.0.255
[R1-ospf-1-area-0.0.0.2]q
[R1-ospf-1]q
[R1]q
<R1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
R2配置如下
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys R2
[R2]int loopback 0
[R2-LoopBack0]ip add 2.2.2.2 32
[R2-LoopBack0]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 10.1.3.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 10.1.4.1 24
[R2-GigabitEthernet0/0/1]int g0/0/2
[R2-GigabitEthernet0/0/2]ip add 10.3.1.1 24
[R2-GigabitEthernet0/0/2]int g0/0/3
[R2-GigabitEthernet0/0/3]ip add 10.3.2.1 24
[R2-GigabitEthernet0/0/3]dis router id
RouterID:2.2.2.2
[R2-GigabitEthernet0/0/3]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 10.1.3.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 10.1.4.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]area 1
[R2-ospf-1-area-0.0.0.1]network 10.3.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]network 10.3.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]q
[R2-ospf-1]q
[R2]q
<R2>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Now saving the current configuration to the slot 17.
Save the configuration successfully.
验证
各个路由器之间互相ping测试,发现都可以ping通。说明实验成功。
问题排查
若出现无法ping通的现象,可以使用如下命令进行排查
//查看路由表
dis ip routing
//查看ospf邻居
dis ospf peer