• 產品與解決方案
  • 行業解決方案
  • 服務
  • 支持
  • 合作夥伴
  • 關於我們

H3C園區盒式交換機 CLI快速配置指南-6W104

  • 發布時間:2025/5/12 19:56:54
  • 瀏覽量:
  • 下載量:

18-OSPF快速配置指南

本章節下載  (330.21 KB)

18-OSPF快速配置指南

OSPF快速配置指南

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Copyright © 2024 bobty下载软件 版權所有,保留一切權利。

非經本公司書麵許可,任何單位和個人不得擅自摘抄、複製本文檔內容的部分或全部,並不得以任何形式傳播。

除bobty下载软件 的商標外,本手冊中出現的其它公司的商標、產品標識及商品名稱,由各自權利人擁有。

本文檔中的信息可能變動,恕不另行通知。



1  配置OSPF引入自治係統外部路由

1.1  簡介

本案例介紹OSPF引入自治係統外部路由的配置方法。

1.2  組網需求

圖1所示,Switch A、Switch B、Switch C和Switch D運行OSPF;Switch C和Switch E運行靜態路由。整個自治係統劃分為3個區域。具體應用需求如下:

·     Switch A和Switch B作為ABR來轉發區域之間的路由。

·     Switch C作為ASBR引入外部路由(靜態路由),要求路由信息可正確的在AS內傳播。

圖1 OSPF引入自治係統外部路由組網圖

 

1.3  數據規劃

設備

Router ID

接口和IP地址

網段和區域

Switch A

1.1.1.1

物理接口:GE1/0/1

VLAN:100

IP地址:192.168.0.1/24

網段:192.168.0.0/24

區域:area 0

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.1.1/24

網段:192.168.1.0/24

區域:area 1

Switch B

2.2.2.2

物理接口:GE1/0/1

VLAN:100

IP地址:192.168.0.2/24

網段:192.168.0.0/24

區域:area 0

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.2.1/24

網段:192.168.2.0/24

區域:area 2

Switch C

3.3.3.3

物理接口:GE1/0/1

VLAN:300

IP地址:172.16.1.1/24

網段:172.16.1.0/24

區域:area 1

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.1.2/24

網段:192.168.1.0/24

區域:area 1

Switch D

4.4.4.4

物理接口:GE1/0/1

VLAN:300

IP地址:172.17.1.1/24

網段:172.17.1.0/24

區域:area 2

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.2.2/24

網段:192.168.2.0/24

區域:area 2

Switch E

-

物理接口:GE1/0/1

VLAN:300

IP地址:172.16.1.2/24

網段:172.16.1.0/24

物理接口:GE1/0/2

VLAN:400

IP地址:10.10.10.1/24

網段:10.10.10.0/24

Host A

-

IP地址:10.10.10.2/24

網段:10.10.10.0/24

Host B

-

IP地址:172.17.1.2/24

網段:172.17.1.0/24

 

1.4  配置步驟

1. Switch A的配置

# 創建VLAN 100和VLAN 200,將接口GE1/0/1加入VLAN 100、接口GE1/0/2加入VLAN 200,並配置VLAN 100的IP地址為192.168.0.1/24,VLAN 200的IP地址為192.168.1.1/24。

<Switch A> system-view

[Switch A] vlan 100

[Switch A-vlan100] port gigabitethernet 1/0/1

[Switch A-vlan100] quit

[Switch A] vlan 200

[Switch A-vlan200] port gigabitethernet 1/0/2

[Switch A-vlan200] quit

[Switch A] interface vlan 100

[Switch A-Vlan-interface100] ip address 192.168.0.1 255.255.255.0

[Switch A-Vlan-interface100] quit

[Switch A] interface vlan 200

[Switch A-Vlan-interface200] ip address 192.168.1.1 255.255.255.0

[Switch A-Vlan-interface200] quit

# 配置全局Router ID為1.1.1.1。

[Switch A] router id 1.1.1.1

# 啟動OSPF進程1,創建區域0,並通告192.168.0.0/24網段;創建區域1,並通告192.168.1.0/24網段。

[Switch A] ospf 1

[Switch A-ospf-1] area 0

[Switch A-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255

[Switch A-ospf-1-area-0.0.0.0] quit

[Switch A-ospf-1] area 1

[Switch A-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255

[Switch A-ospf-1] quit

# 保存配置。

[Switch A] save force

2. Switch B的配置

# 創建VLAN 100和VLAN 200,將接口GE1/0/1加入VLAN 100、接口GE1/0/2加入VLAN 200,並配置VLAN 100的IP地址為192.168.0.2/24,VLAN 200的IP地址為192.168.2.1/24。

<Switch B> system-view

[Switch B] vlan 100

[Switch B-vlan100] port gigabitethernet 1/0/1

[Switch B-vlan100] quit

[Switch B] vlan 200

[Switch B-vlan200] port gigabitethernet 1/0/2

[Switch B-vlan200] quit

[Switch B] interface vlan 100

[Switch B-Vlan-interface100] ip address 192.168.0.2 255.255.255.0

[Switch B-Vlan-interface100] quit

[Switch B] interface vlan 200

[Switch B-Vlan-interface200] ip address 192.168.2.1 255.255.255.0

[Switch B-Vlan-interface200] quit

# 配置全局Router ID為2.2.2.2。

[Switch B] router id 2.2.2.2

# 啟動OSPF進程1,創建區域0,並通告192.168.0.0/24網段;創建區域2,並通告192.168.2.0/24網段。

[Switch B] ospf 1

[Switch B-ospf-1] area 0

[Switch B-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255

[Switch B-ospf-1-area-0.0.0.0] quit

[Switch B-ospf-1] area 2

[Switch B-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255

[Switch B-ospf-1-area-0.0.0.2] quit

[Switch B-ospf-1] quit

# 保存配置。

[Switch B] save force

3. Switch C的配置

# 創建VLAN 200和VLAN 300,將接口GE1/0/1加入VLAN 300、接口GE1/0/2加入VLAN 200,並配置VLAN 300的IP地址為172.16.1.1/24,VLAN 200的IP地址為192.168.1.2/24。

<Switch C> system-view

[Switch C] vlan 300

[Switch C-vlan300] port gigabitethernet 1/0/1

[Switch C-vlan300] quit

[Switch C] vlan 200

[Switch C-vlan200] port gigabitethernet 1/0/2

[Switch C-vlan200] quit

[Switch C] interface vlan 300

[Switch C-Vlan-interface300] ip address 172.16.1.1 255.255.255.0

[Switch C-Vlan-interface300] quit

[Switch C] interface vlan 200

[Switch C-Vlan-interface200] ip address 192.168.1.2 255.255.255.0

[Switch C-Vlan-interface200] quit

# 配置靜態路由,其目的網段為10.10.10.0/24,下一跳為172.16.1.2。

[Switch C] ip route-static 10.10.10.0 24 172.16.1.2

# 配置全局Router ID為3.3.3.3。

[Switch C] router id 3.3.3.3

# 啟動OSPF進程1,創建區域1,並通告192.168.1.0/24網段和172.16.1.0/24網段。

[Switch C] ospf 1

[Switch C-ospf-1] area 1

[Switch C-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255

[Switch C-ospf-1-area-0.0.0.1] network 172.16.1.0 0.0.0.255

[Switch C-ospf-1-area-0.0.0.1] quit

# 配置OSPF引入靜態路由。

[Switch C-ospf-1] import-route static

[Switch C-ospf-1] quit

# 保存配置。

[Switch C] save force

4. Switch D的配置

# 創建VLAN 200和VLAN 300,將接口GE1/0/1加入VLAN 300、接口GE1/0/2加入VLAN 200,並配置VLAN 300的IP地址為172.17.1.1/24,VLAN 200的IP地址為192.168.2.2/24。

<Switch D> system-view

[Switch D] vlan 300

[Switch D-vlan300] port gigabitethernet 1/0/1

[Switch D-vlan300] quit

[Switch D] vlan 200

[Switch D-vlan200] port gigabitethernet 1/0/2

[Switch D-vlan200] quit

[Switch D] interface vlan 300

[Switch D-Vlan-interface300] ip address 172.17.1.1 255.255.255.0

[Switch D-Vlan-interface300] quit

[Switch D] interface vlan 200

[Switch D-Vlan-interface200] ip address 192.168.2.2 255.255.255.0

[Switch D-Vlan-interface200] quit

# 配置全局Router ID為4.4.4.4。

[Switch D] router id 4.4.4.4

# 啟動OSPF進程1,創建區域2,並通告192.168.2.0/24網段和172.17.1.0/24網段。

[Switch D] ospf 1

[Switch D-ospf-1] area 2

[Switch D-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255

[Switch D-ospf-1-area-0.0.0.2] network 172.17.1.0 0.0.0.255

[Switch D-ospf-1-area-0.0.0.2] quit

[Switch D-ospf-1] quit

# 保存配置。

[Switch D] save force

5. Switch E的配置

# 創建VLAN 300和VLAN 400,將接口GE1/0/1加入VLAN 300、接口GE1/0/2加入VLAN 400,並配置VLAN 300的IP地址為172.16.1.2/24,VLAN 400的IP地址為10.10.10.1/24。

<Switch E> system-view

[Switch E] vlan 300

[Switch E-vlan300] port gigabitethernet 1/0/1

[Switch E-vlan300] quit

[Switch E] vlan 400

[Switch E-vlan400] port gigabitethernet 1/0/2

[Switch E-vlan400] quit

[Switch E] interface vlan 300

[Switch E-Vlan-interface300] ip address 172.16.1.2 255.255.255.0

[Switch E-Vlan-interface300] quit

[Switch E] interface vlan 400

[Switch E-Vlan-interface400] ip address 10.10.10.1 255.255.255.0

[Switch E-Vlan-interface400] quit

# 配置缺省路由,下一跳為172.16.1.1。

[Switch E] ip route-static 0.0.0.0 0 172.16.1.1

# 保存配置。

[Switch E] save force

1.5  驗證配置

# 查看Switch A的路由表,存在到172.16.1.0172.17.1.0192.168.2.0的路由,以及學習到的外部引入的靜態路由。

[Switch A] display ip routing-table

Destinations : 20       Routes : 20

 

Destination/Mask   Proto   Pre Cost        NextHop         Interface

 

0.0.0.0/32         Direct  0   0           127.0.0.1       InLoop0

10.10.10.0/24      O_ASE2  150 1           192.168.1.2     Vlan200

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

# Host A可以ping通Host B。

C:\Users\HostA>ping 172.17.1.2

正在 Ping 172.17.1.2 具有 32 字節的數據:

來自 172.17.1.2 的回複: 字節=32 時間=3ms TTL=255

來自 172.17.1.2 的回複: 字節=32 時間=1ms TTL=255

來自 172.17.1.2 的回複: 字節=32 時間<1ms TTL=255

來自 172.17.1.2 的回複: 字節=32 時間=2ms TTL=255

 

172.17.1.2 的 Ping 統計信息:

    數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),

往返行程的估計時間(以毫秒為單位):

    最短 = 0ms,最長 = 3ms,平均 = 1ms

1.6  配置文件

·     Switch A:

#

 router id 1.1.1.1

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

#

interface Vlan-interface100

 ip address 192.168.0.1 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.1.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 100

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

·     Switch B:

#

 router id 2.2.2.2

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

#

interface Vlan-interface100

 ip address 192.168.0.2 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.2.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 100

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

·     Switch C:

#

 router id 3.3.3.3

#

ospf 1

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

  network 172.16.1.0 0.0.0.255

#

interface Vlan-interface200

 ip address 192.168.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.16.1.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 300

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

·     Switch D:

#

 router id 4.4.4.4

#

ospf 1

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

  network 172.17.1.0 0.0.0.255

#

interface Vlan-interface200

 ip address 192.168.2.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.17.1.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 300

#

interface GigabitEthernet1/0/2

 port access vlan 200

 

#

·     Switch E:

#

interface Vlan-interface200

 ip address 10.10.10.1 255.255.255.0

#

interface Vlan-interface300

 ip address 172.16.1.2 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 300

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

 ip route-static 0.0.0.0 0 172.16.1.1

#

1.7  相關資料

·     產品配套“三層技術-IP路由配置指導”中的“OSPF”。

·     產品配套“三層技術-IP路由命令參考”中的“OSPF”。


 

2  單區域OSPF基本功能配置

2.1  簡介

本案例介紹單區域OSPF基本功能的配置方法。

2.2  組網需求

圖2所示,Switch A和Switch B運行OSPF,要求Host A和Host B通過運行OSPF協議的Switch A和Switch B實現互聯互通。

圖2 單區域OSPF基本功能組網圖

 

2.3  配置步驟

1. Switch A的配置

# 創建VLAN 10和VLAN 20,將接口GE1/0/1加入VLAN 10、接口GE1/0/2加入VLAN 20,並配置VLAN 10的IP地址為192.168.10.1/24,VLAN 20的IP地址為192.168.20.1/24。

<Switch A> system-view

[Switch A] vlan 10

[Switch A-vlan10] port gigabitethernet 1/0/1

[Switch A-vlan10] quit

[Switch A] vlan 20

[Switch A-vlan20] port gigabitethernet 1/0/2

[Switch A-vlan20] quit

[Switch A] interface vlan 10

[Switch A-Vlan-interface10] ip address 192.168.10.1 255.255.255.0

[Switch A-Vlan-interface10] quit

[Switch A] interface vlan 20

[Switch A-Vlan-interface20] ip address 192.168.20.1 255.255.255.0

[Switch A-Vlan-interface20] quit

# 配置全局Router ID為1.1.1.1。

[Switch A] router id 1.1.1.1

# 啟動OSPF進程1,創建區域0,並通告192.168.10.0/24網段和192.168.20.0/24網段。

[Switch A] ospf 1

[Switch A-ospf-1] area 0

[Switch A-ospf-1-area-0.0.0.0] network 192.168.10.0 0.0.0.255

[Switch A-ospf-1-area-0.0.0.0] network 192.168.20.0 0.0.0.255

[Switch A-ospf-1-area-0.0.0.0] quit

[Switch A-ospf-1] quit

# 保存配置。

[Switch A] save force

2. Switch B的配置

# 創建VLAN 20和VLAN 30,將接口GE1/0/1加入VLAN 30、接口GE1/0/2加入VLAN 20,並配置VLAN 30的IP地址為192.168.30.1/24,VLAN 20的IP地址為192.168.20.2/24。

<Switch B> system-view

[Switch B] vlan 30

[Switch B-vlan30] port gigabitethernet 1/0/1

[Switch B-vlan30] quit

[Switch B] vlan 20

[Switch B-vlan20] port gigabitethernet 1/0/2

[Switch B-vlan20] quit

[Switch B] interface vlan 30

[Switch B-Vlan-interface30] ip address 192.168.30.1 255.255.255.0

[Switch B-Vlan-interface30] quit

[Switch B] interface vlan 20

[Switch B-Vlan-interface20] ip address 192.168.20.2 255.255.255.0

[Switch B-Vlan-interface20] quit

# 配置全局Router ID為2.2.2.2。

[Switch B] router id 2.2.2.2

# 啟動OSPF進程1,創建區域0,並通告192.168.20.0/24網段和192.168.30.0/24網段。

[Switch B] ospf 1

[Switch B-ospf-1] area 0

[Switch B-ospf-1-area-0.0.0.0] network 192.168.20.0 0.0.0.255

[Switch B-ospf-1-area-0.0.0.0] network 192.168.30.0 0.0.0.255

[Switch B-ospf-1-area-0.0.0.0] quit

[Switch B-ospf-1] quit

# 保存配置。

[Switch B] save force

2.4  驗證配置

# 查看Switch A的OSPF鄰居。

[Switch A] display ospf peer

 

         OSPF Process 1 with Router ID 1.1.1.1

               Neighbor Brief Information

 

 Area: 0.0.0.0

 Router ID       Address         Pri Dead-Time  State             Interface

 2.2.2.2         192.168.20.2    1   30         Full/DR -         Vlan20

# 查看Switch A的OSPF路由信息。

[Switch A] display ospf routing

 

         OSPF Process 1 with Router ID 1.1.1.1

 

                  Routing Table

 

                Topology base (MTID 0)

 

 Routing for network

 

 Destination        Cost     Type    NextHop         AdvRouter       Area

 192.168.10.0/24    1        Stub    0.0.0.0         192.168.20.1    0.0.0.0

 192.168.30.0/24    2        Stub    192.168.20.2    192.168.20.2    0.0.0.0

 192.168.20.0/24    1        Transit 0.0.0.0         192.168.20.1    0.0.0.0

# 查看Switch A的路由表信息,存在到達192.168.30.0/24網段的路由。

[Switch A] display ip routing-table

 

Destinations : 17       Routes : 17

 

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

192.168.10.0/24    Direct  0   0           192.168.10.1    Vlan10

192.168.10.0/32    Direct  0   0           192.168.10.1    Vlan10

192.168.10.1/32    Direct  0   0           127.0.0.1       InLoop0

192.168.10.255/32  Direct  0   0           192.168.10.1    Vlan10

192.168.20.0/24    Direct  0   0           192.168.20.1    Vlan20

192.168.20.0/32    Direct  0   0           192.168.20.1    Vlan20

192.168.20.1/32    Direct  0   0           127.0.0.1       InLoop0

192.168.20.255/32  Direct  0   0           192.168.20.1    Vlan20

192.168.30.0/24    O_INTRA 10  2           192.168.20.2    Vlan20

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

# Host A可以ping通Host B。

C:\Users\HostA>ping 192.168.30.2

正在 Ping 192.168.30.2 具有 32 字節的數據:

來自 192.168.30.2 的回複: 字節=32 時間=3ms TTL=255

來自 192.168.30.2 的回複: 字節=32 時間=1ms TTL=255

來自 192.168.30.2 的回複: 字節=32 時間<1ms TTL=255

來自 192.168.30.2 的回複: 字節=32 時間=2ms TTL=255

 

192.168.30.2 的 Ping 統計信息:

    數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),

往返行程的估計時間(以毫秒為單位):

    最短 = 2ms,最長 = 3ms,平均 = 2ms

2.5  配置文件

·     Switch A:

#

 router id 1.1.1.1

#

ospf 1

 area 0.0.0.0

  network 192.168.10.0 0.0.0.255

  network 192.168.20.0 0.0.0.255

#

interface Vlan-interface10

 ip address 192.168.10.1 255.255.255.0

#

interface Vlan-interface20

 ip address 192.168.20.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 10

#

interface GigabitEthernet1/0/2

 port access vlan 20

#

·     Switch B:

#

 router id 2.2.2.2

#

ospf 1

 area 0.0.0.0

  network 192.168.20.0 0.0.0.255

  network 192.168.30.0 0.0.0.255

#

interface Vlan-interface20

 ip address 192.168.20.2 255.255.255.0

#

interface Vlan-interface30

 ip address 192.168.30.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 30

#

interface GigabitEthernet1/0/2

 port access vlan 20

#

2.6  相關資料

·     產品配套“三層技術-IP路由配置指導”中的“OSPF”。

·     產品配套“三層技術-IP路由命令參考”中的“OSPF”。


 

3  多區域OSPF基本功能配置

3.1  簡介

本案例介紹多區域OSPF基本功能的配置方法。

3.2  組網需求

圖3所示,Switch A、Switch B、Switch C、Switch D都運行OSPF,並將整個自治係統劃分為3個區域。其中Switch A和Switch B作為ABR來轉發區域之間的路由。配置完成後,每台交換機都應學到AS內的到所有網段的路由。

圖3 多區域OSPF基本功能組網圖

 

3.3  數據規劃

設備

Router ID

接口和IP地址

網段和區域

Switch A

1.1.1.1

物理接口:GE1/0/1

VLAN:100

IP地址:192.168.0.1/24

網段:192.168.0.0/24

區域:area 0

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.1.1/24

網段:192.168.1.0/24

區域:area 1

Switch B

2.2.2.2

物理接口:GE1/0/1

VLAN:100

IP地址:192.168.0.2/24

網段:192.168.0.0/24

區域:area 0

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.2.1/24

網段:192.168.2.0/24

區域:area 2

Switch C

3.3.3.3

物理接口:GE1/0/1

VLAN:300

IP地址:172.16.1.1/24

網段:172.16.1.0/24

區域:area 1

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.1.2/24

網段:192.168.1.0/24

區域:area 1

Switch D

4.4.4.4

物理接口:GE1/0/1

VLAN:300

IP地址:172.17.1.1/24

網段:172.17.1.0/24

區域:area 2

物理接口:GE1/0/2

VLAN:200

IP地址:192.168.2.2/24

網段:192.168.2.0/24

區域:area 2

Host A

-

IP地址:172.16.1.2/24

網段:172.16.1.0/24

Host B

-

IP地址:172.17.1.2/24

網段:172.17.1.0/24

 

3.4  配置步驟

1. Switch A的配置

# 創建VLAN 100和VLAN 200,將接口GE1/0/1加入VLAN 100、接口GE1/0/2加入VLAN 200,並配置VLAN 100的IP地址為192.168.0.1/24,VLAN 200的IP地址為192.168.1.1/24。

<Switch A> system-view

[Switch A] vlan 100

[Switch A-vlan100] port gigabitethernet 1/0/1

[Switch A-vlan100] quit

[Switch A] vlan 200

[Switch A-vlan200] port gigabitethernet 1/0/2

[Switch A-vlan200] quit

[Switch A] interface vlan 100

[Switch A-Vlan-interface100] ip address 192.168.0.1 255.255.255.0

[Switch A-Vlan-interface100] quit

[Switch A] interface vlan 200

[Switch A-Vlan-interface200] ip address 192.168.1.1 255.255.255.0

[Switch A-Vlan-interface200] quit

# 配置全局Router ID為1.1.1.1。

[Switch A] router id 1.1.1.1

# 啟動OSPF進程1,創建區域0,並通告192.168.0.0/24網段;創建區域1,並通告192.168.1.0/24網段。

[Switch A] ospf 1

[Switch A-ospf-1] area 0

[Switch A-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255

[Switch A-ospf-1-area-0.0.0.0] quit

[Switch A-ospf-1] area 1

[Switch A-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255

[Switch A-ospf-1-area-0.0.0.1] quit

[Switch A-ospf-1] quit

# 保存配置。

[Switch A] save force

2. Switch B的配置

# 創建VLAN 100和VLAN 200,將接口GE1/0/1加入VLAN 100、接口GE1/0/2加入VLAN 200,並配置VLAN 100的IP地址為192.168.0.2/24,VLAN 200的IP地址為192.168.2.1/24。

<Switch B> system-view

[Switch B] vlan 100

[Switch B-vlan100] port gigabitethernet 1/0/1

[Switch B-vlan100] quit

[Switch B] vlan 200

[Switch B-vlan200] port gigabitethernet 1/0/2

[Switch B-vlan200] quit

[Switch B] interface vlan 100

[Switch B-Vlan-interface100] ip address 192.168.0.2 255.255.255.0

[Switch B-Vlan-interface100] quit

[Switch B] interface vlan 200

[Switch B-Vlan-interface200] ip address 192.168.2.1 255.255.255.0

[Switch B-Vlan-interface200] quit

# 配置全局Router ID為2.2.2.2。

[Switch B] router id 2.2.2.2

# 啟動OSPF進程1,創建區域0,並通告192.168.0.0/24網段;創建區域2,並通告192.168.2.0/24網段。

[Switch B] ospf 1

[Switch B-ospf-1] area 0

[Switch B-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255

[Switch B-ospf-1-area-0.0.0.0] quit

[Switch B-ospf-1] area 2

[Switch B-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255

[Switch B-ospf-1-area-0.0.0.2] quit

[Switch B-ospf-1] quit

# 保存配置。

[Switch B] save force

3. Switch C的配置

# 創建VLAN 200和VLAN 300,將接口GE1/0/1加入VLAN 300、接口GE1/0/2加入VLAN 200,並配置VLAN 300的IP地址為172.16.1.1/24,VLAN 200的IP地址為192.168.1.2/24。

<Switch C> system-view

[Switch C] vlan 300

[Switch C-vlan300] port gigabitethernet 1/0/1

[Switch C-vlan300] quit

[Switch C] vlan 200

[Switch C-vlan200] port gigabitethernet 1/0/2

[Switch C-vlan200] quit

[Switch C] interface vlan 300

[Switch C-Vlan-interface300] ip address 172.16.1.1 255.255.255.0

[Switch C-Vlan-interface300] quit

[Switch C] interface vlan 200

[Switch C-Vlan-interface200] ip address 192.168.1.2 255.255.255.0

[Switch C-Vlan-interface200] quit

# 配置全局Router ID為3.3.3.3。

[Switch C] router id 3.3.3.3

# 啟動OSPF進程1,創建區域1,並通告192.168.1.0/24網段和172.16.1.0/24網段。

[Switch C] ospf 1

[Switch C-ospf-1] area 1

[Switch C-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255

[Switch C-ospf-1-area-0.0.0.1] network 172.16.1.0 0.0.0.255

[Switch C-ospf-1-area-0.0.0.1] quit

[Switch C-ospf-1] quit

# 保存配置。

[Switch C] save force

4. Switch D的配置

# 創建VLAN 200和VLAN 300,將接口GE1/0/1加入VLAN 300、接口GE1/0/2加入VLAN 200,並配置VLAN 300的IP地址為172.17.1.1/24,VLAN 200的IP地址為192.168.2.2/24。

<Switch D> system-view

[Switch D] vlan 300

[Switch D-vlan300] port gigabitethernet 1/0/1

[Switch D-vlan300] quit

[Switch D] vlan 200

[Switch D-vlan200] port gigabitethernet 1/0/2

[Switch D-vlan200] quit

[Switch D] interface vlan 300

[Switch D-Vlan-interface300] ip address 172.17.1.1 255.255.255.0

[Switch D-Vlan-interface300] quit

[Switch D] interface vlan 200

[Switch D-Vlan-interface200] ip address 192.168.2.2 255.255.255.0

[Switch D-Vlan-interface200] quit

# 配置全局Router ID為4.4.4.4。

[Switch D] router id 4.4.4.4

# 啟動OSPF進程1,創建區域2,並通告192.168.2.0/24網段和172.17.1.0/24網段。

[Switch D] ospf 1

[Switch D-ospf-1] area 2

[Switch D-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255

[Switch D-ospf-1-area-0.0.0.2] network 172.17.1.0 0.0.0.255

[Switch D-ospf-1-area-0.0.0.2] quit

[Switch D-ospf-1] quit

# 保存配置。

[Switch D] save force

3.5  驗證配置

# 查看Switch A的OSPF鄰居。

[Switch A] display ospf peer

 

         OSPF Process 1 with Router ID 1.1.1.1

               Neighbor Brief Information

 

 Area: 0.0.0.0

 Router ID       Address         Pri Dead-Time  State             Interface

 2.2.2.2         192.168.0.2     1   33         Full/DR           Vlan100

 

 Area: 0.0.0.1

 Router ID       Address         Pri Dead-Time  State             Interface

 3.3.3.3         192.168.1.2     1   34         Full/DR           Vlan200

# 查看Switch A的路由表,存在到172.16.1.0172.17.1.0192.168.2.0的路由。

[Switch A] 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

# Host A可以ping通Host B。

C:\Users\HostA>ping 172.17.1.2

正在 Ping 192.168.30.2 具有 32 字節的數據:

來自 172.17.1.2 的回複: 字節=32 時間=3ms TTL=255

來自 172.17.1.2 的回複: 字節=32 時間=1ms TTL=255

來自 172.17.1.2 的回複: 字節=32 時間<1ms TTL=255

來自 172.17.1.2 的回複: 字節=32 時間=2ms TTL=255

 

172.17.1.2 的 Ping 統計信息:

    數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),

往返行程的估計時間(以毫秒為單位):

    最短 = 2ms,最長 = 3ms,平均 = 2ms

3.6  配置文件

·     Switch A:

#

 router id 1.1.1.1

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

#

interface Vlan-interface100

 ip address 192.168.0.1 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.1.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 100

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

·     Switch B:

#

 router id 2.2.2.2

#

ospf 1

 area 0.0.0.0

  network 192.168.0.0 0.0.0.255

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

#

interface Vlan-interface100

 ip address 192.168.0.2 255.255.255.0

#

interface Vlan-interface200

 ip address 192.168.2.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 100

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

·     Switch C:

#

 router id 3.3.3.3

#

ospf 1

 area 0.0.0.1

  network 192.168.1.0 0.0.0.255

  network 172.16.1.0 0.0.0.255

#

interface Vlan-interface200

 ip address 192.168.1.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.16.1.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 300

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

·     Switch D:

#

 router id 4.4.4.4

#

ospf 1

 area 0.0.0.2

  network 192.168.2.0 0.0.0.255

  network 172.17.1.0 0.0.0.255

#

interface Vlan-interface200

 ip address 192.168.2.2 255.255.255.0

#

interface Vlan-interface300

 ip address 172.17.1.1 255.255.255.0

#

interface GigabitEthernet1/0/1

 port access vlan 300

#

interface GigabitEthernet1/0/2

 port access vlan 200

#

3.7  相關資料

·     產品配套“三層技術-IP路由配置指導”中的“OSPF”。

·     產品配套“三層技術-IP路由命令參考”中的“OSPF”。

不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!

BOB登陆
官網
聯係我們