网络拓扑图:
相关配置:
所有子网掩码:255.255.255.0
HostA: 10.1.1.1
GW: 10.1.1.2
HostB: 10.2.1.1
GW: 10.2.1.2
HostC: 10.3.1.1
GW: 10.3.1.2
HostD: 10.4.1.1
GW: 10.4.1.2
[RouterA]int e0
[RouterA-Ethernet0/0]ip addr 10.1.1.1 255.255.255.0
[RouterA-Ethernet0/0]undo shut
[RouterA-Ethernet0/0]int e1
[RouterA-Ethernet0/1]ip addr 10.2.1.1 255.255.255.0
[RouterA-Ethernet0/1]undo shut
[RouterA-Ethernet0/1]int s0
[RouterA-Serial0/0]ip addr 10.6.1.1 255.255.255.0
[RouterA-Serial0/0]undo shut
[RouterA]ospf
[RouterA-ospf-1]area 0
[RouterA-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.0]network 10.2.1.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.0]network 10.6.1.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.0]quit
[RouterB]int e0
[RouterB-Ethernet0/0]ip addr 10.3.1.1 255.255.255.0
[RouterB-Ethernet0/0]undo shut
[RouterB-Ethernet0/0]int e1
[RouterB-Ethernet0/1]ip addr 10.4.1.1 255.255.255.0
[RouterB-Ethernet0/1]undo shut
[RouterB-Ethernet0/1]int s0
[RouterB-Serial0/0]ip addr 10.6.1.0 255.255.255.0
[RouterB-Serial0/0]undo shut
[RouterB-Serial0/0]quit
[RouterB]ospf
[RouterB-ospf-1]area 0
[RouterB-ospf-1-area-0.0.0.0]network 10.3.1.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.0]network 10.4.1.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.0]network 10.6.1.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.0]quit
[RouterB]
实验结果:各网段互通!