1 配置需求或說明
1.1適用產品系列
本案例適用于如S7506E 、S5130S-28S-SI、S5500V2-24P-WiNet等支持OSPF協議的V7交換機。
1.2配置需求
SWA、SWB、SWC、SWD都運行OSPF,并將整個自治系統劃分為3個區域。其中Switch A和Switch B作為ABR來轉發區域之間的路由。配置完成后,每臺交換機都應學到AS內的到所有網段的路由。
2 組網圖

3 配置步驟
3.1 SWA配置
#創建vlan100和vlan200,并把G1/0/1口加入vlan100、1/0/2口加入vlan200 ,并且配置vlan100和vlan200 的虛接口地址
<SWA>system-view
System View: return to User View with Ctrl+Z.
[SWA]vlan 100
[SWA-vlan100]port GigabitEthernet 1/0/1
[SWA-vlan100]quit
[SWA]vlan 200
[SWA-vlan200]port GigabitEthernet 1/0/2
[SWA-vlan200]quit
[SWA]interface vlan 100
[SWA-Vlan-interface100]ip address 192.168.0.1 255.255.255.0
[SWA-Vlan-interface100]quit
[SWA]interface vlan 200
[SWA-Vlan-interface200]ip address 192.168.1.1 255.255.255.0
[SWA-Vlan-interface200]quit
#啟動ospf協議,并設置路由器的router id
[SWA]ospf 1 router-id 192.168.1.1
#配置區域0并且發布網段
[SWA-ospf-1]area 0
[SWA-ospf-1-area-0.0.0.0]network 192.168.0.0 0.0.0.255
[SWA-ospf-1-area-0.0.0.0]quit
#配置區域1并且發布網段
[SWA-ospf-1]area 1
[SWA-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[SWA-ospf-1-area-0.0.0.1]quit
[SWA-ospf-1]quit
#保存配置
[SWA]save force
3.2 SWB配置
#創建vlan100和vlan200,并把G1/0/1口加入vlan100、1/0/2口加入vlan200 ,并且配置vlan100和vlan200 的虛接口地址
<SWB>system-view
System View: return to User View with Ctrl+Z.
[SWB]vlan 100
[SWB-vlan100]port GigabitEthernet 1/0/1
[SWB-vlan100]quit
[SWB]vlan 200
[SWB-vlan200]port GigabitEthernet 1/0/2
[SWB-vlan200]quit
[SWB]interface vlan 100
[SWB-Vlan-interface100]ip address 192.168.0.2 255.255.255.0
[SWB-Vlan-interface100]quit
[SWB]interface vlan 200
[SWB-Vlan-interface200]ip address 192.168.2.1 255.255.255.0
[SWB-Vlan-interface200]quit
#啟動ospf協議,并設置路由器的router id
[SWB]ospf 1 router-id 192.168.2.1
#配置區域0并且發布網段
[SWB-ospf-1]area 0
[SWB-ospf-1-area-0.0.0.0]network 192.168.0.0 0.0.0.255
[SWB-ospf-1-area-0.0.0.0]quit
#配置區域2并且發布網段
[SWB-ospf-1]area 2
[SWB-ospf-1-area-0.0.0.2]network 192.168.2.0 0.0.0.255
[SWB-ospf-1-area-0.0.0.2]quit
[SWB-ospf-1]quit
#保存配置
[SWB]save force
3.3 SWC配置
#創建vlan200和vlan300,并把G1/0/1口加入vlan300、1/0/2口加入vlan200 ,并且配置vlan300和vlan200 的虛接口地址
<SWC>system-view
System View: return to User View with Ctrl+Z.
[SWC]vlan 300
[SWC-vlan300]port GigabitEthernet 1/0/1
[SWC-vlan300]quit
[SWC]vlan 200
[SWC-vlan200]port GigabitEthernet 1/0/2
[SWC-vlan200]quit
[SWC]interface vlan 300
[SWC-Vlan-interface300]ip address 172.16.1.1 255.255.255.0
[SWC-Vlan-interface300]quit
[SWC]interface vlan 200
[SWC-Vlan-interface200]ip address 192.168.1.2 255.255.255.0
[SWC-Vlan-interface200]quit
#啟動ospf協議,并設置路由器的router id
[SWC]ospf 1 router-id 192.168.1.2
#配置區域1并且發布網段
[SWC-ospf-1]area 1
[SWC-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[SWC-ospf-1-area-0.0.0.1]network 172.16.1.0 0.0.0.255
[SWC-ospf-1-area-0.0.0.1]quit
[SWC-ospf-1]quit
#保存配置
[SWC]save force
3.4 SWD配置
#創建vlan200和vlan300,并把G1/0/1口加入vlan300、1/0/2口加入vlan200 ,并且配置vlan300和vlan200 的虛接口地址
<SWD>system-view
System View: return to User View with Ctrl+Z.
[SWD]vlan 300
[SWD-vlan300]port GigabitEthernet 1/0/1
[SWD-vlan300]quit
[SWD]vlan 200
[SWD-vlan200]port GigabitEthernet 1/0/2
[SWD-vlan200]quit
[SWD]interface vlan 300
[SWD-Vlan-interface300]ip address 172.17.1.1 255.255.255.0
[SWD-Vlan-interface300]quit
[SWD]interface vlan 200
[SWD-Vlan-interface200]ip address 192.168.2.2 255.255.255.0
[SWD-Vlan-interface200]quit
#啟動ospf協議,并設置路由器的router id
[SWD]ospf 1 router-id 192.168.2.2
#配置區域1并且發布網段
[SWD-ospf-1]area 2
[SWD-ospf-1-area-0.0.0.2]network 192.168.2.0 0.0.0.255
[SWD-ospf-1-area-0.0.0.2]network 172.17.1.0 0.0.0.255
[SWD-ospf-1-area-0.0.0.2]quit
[SWD-ospf-1]quit
#保存配置
[SWD]save force
3.5 驗證配置
# 查看Switch A的OSPF鄰居,Full是正常狀態
[SWA]display ospf peer
OSPF Process 1 with Router ID 192.168.1.1
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
192.168.2.1 192.168.0.2 1 32 Full/BDR Vlan100
Area: 0.0.0.1
Router ID Address Pri Dead-Time State Interface
192.168.1.2 192.168.1.2 1 36 Full/BDR Vlan200
#查看Switch A的OSPF路由信息
[SWA]display ospf routing
OSPF Process 1 with Router ID 192.168.1.1
Routing Table
Topology base (MTID 0)
Routing for network
Destination Cost Type NextHop AdvRouter Area
172.16.1.0/24 2 Stub 192.168.1.2 192.168.1.2 0.0.0.1
172.17.1.0/24 3 Inter 192.168.0.2 192.168.2.1 0.0.0.0
192.168.0.0/24 1 Transit 0.0.0.0 192.168.1.1 0.0.0.0
192.168.1.0/24 1 Transit 0.0.0.0 192.168.1.1 0.0.0.1
192.168.2.0/24 2 Inter 192.168.0.2 192.168.2.1 0.0.0.0
Total nets: 5
Intra area: 3 Inter area: 2 ASE: 0 NSSA: 0
#查看Switch A的路由表信息,有到172.16.1.0、172.17.1.0、192.168.2.0的路由
[SWA]display ip routing-table
Destinations : 19 Routes : 19
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
172.16.1.0/24 O_INTRA 10 2 192.168.1.2 Vlan200
172.17.1.0/24 O_INTER 10 3 192.168.0.2 Vlan100
192.168.0.0/24 Direct 0 0 192.168.0.1 Vlan100
192.168.0.0/32 Direct 0 0 192.168.0.1 Vlan100
192.168.0.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.0.255/32 Direct 0 0 192.168.0.1 Vlan100
192.168.1.0/24 Direct 0 0 192.168.1.1 Vlan200
192.168.1.0/32 Direct 0 0 192.168.1.1 Vlan200
192.168.1.1/32 Direct 0 0 127.0.0.1 InLoop0
192.168.1.255/32 Direct 0 0 192.168.1.1 Vlan200
192.168.2.0/24 O_INTER 10 2 192.168.0.2 Vlan100
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
# PC1 ping PC2 正常通信
C:Usersmfw2656>ping 172.17.1.2
Ping 172.17.1.2 (172.17.1.2): 56 data bytes, press CTRL_C to break
56 bytes from 172.17.1.2: icmp_seq=0 ttl=254 time=8.000 ms
56 bytes from 172.17.1.2: icmp_seq=1 ttl=254 time=2.000 ms
56 bytes from 172.17.1.2: icmp_seq=2 ttl=254 time=3.000 ms
56 bytes from 172.17.1.2: icmp_seq=3 ttl=254 time=3.000 ms
172.17.1.2的 Ping 統計信息:
數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),
返行程的估計時間(以毫秒為單位):
最短 = 2ms,最長 = 3ms,平均 = 2ms