R1:
<Huawei>system-view
[Huawei]sysname R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 10.10.1.1 24
[R1-GigabitEthernet0/0/1]quit
[R1]ospf 1 //开启ospf,进程号为1
[R1-ospf-1]area 0 //将两台路由器放入区域0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 //添加直连网络(网段号+反掩码)
[R1-ospf-1-area-0.0.0.0]network 10.10.1.0 0.0.0.255
R2:
<Huawei>sys
[Huawei]sys R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 10.10.1.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[R2-GigabitEthernet0/0/1]quit
[R2]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]net 10.10.1.0 0.0.0.255
Ping测试