天天看點

自制OSPF配置實驗大全

OSPF綜合實驗(gns模拟器)

<b> </b>

注意點:

Ospf實驗推薦用gns制作

//圖中的交換機可以視覺忽略或縮小成一個點。(^

v^)

Ospf

實驗拓撲圖

自制OSPF配置實驗大全

目錄

OSPF綜合實驗... 1

Ospf實驗拓撲圖... 1

1.Ospf 基礎配置... 1

2.環回口改成點到點網絡... 2

3.改優先級... 2

4.ospf的手動彙總... 2

5.ospf認證... 2

6.ospf釋出預設路由更新... 2

7.孤島區域和區域分割... 2

8.STUB 和

NSSA的配置... 2

1.Ospf 

基礎配置

R1:

R1#conf t

R1(config)#inte0/0

R1(config-if)#ipadd 14.14.14.1 255.255.255.0

R1(config-if)#noshut

R1(config-if)#intlo0

R1(config-if)#ipadd 10.1.1.1 255.255.255.0

R1(config-if)#end

R1(config)#routerospf 1

R1(config-router)#router-id1.1.1.1

R1(config-router)#net10.1.1.0 0.0.0.255 a 1

R1(config-router)#net14.14.14.0 0.0.0.255 a 1

R2:

R2#conf t

R2(config)#inte0/1

R2(config-if)#ipadd  123.123.123.2

255.255.255.0

R2(config-if)#noshut

R2(config-if)#intlo0

R2(config-if)#ipadd 20.2.2.2 255.255.255.0

R2(config-if)#end

R2(config)#routerospf 1

R2(config-router)#router-id2.2.2.2

R2(config-router)#net123.123.123.2 0.0.0.0 a

R2(config-router)#net20.2.2.2 0.0.0.0 a 0

R2(config-router)#end

R3:

R3#conf t

R3(config)#inte0/1

R3(config-if)#ipadd 123.123.123.3 255.255.255.0

R3(config-if)#noshut

R3(config-if)#exit

R3(config)#routerospf 1

R3(config-router)#router-id3.3.3.3

R3(config-router)#net123.123.123.3 0.0.0.0 a 0

R3(config-router)#end

R4:

R4#conf t

R4(config)#inte0/0

R4(config-if)#ipadd 14.14.14.4 255.255.255.0

R4(config-if)#noshut

R4(config-if)#inte0/1

R4(config-if)#ipadd 123.123.123.4 255.255.255.0

R4(config)#intlo0

R4(config-if)#ipadd 90.9.9.9 255.255.255.0

R4(config-if)#end

R4(config)#routerospf 1

R4(config-router)#router

R4(config-router)#router-id4.4.4.4

R4(config-router)#net14.14.14.0 0.0.0.255 a 1

R4(config-router)#net123.123.123.4 0.0.0.0 a 0

R4(config-router)#end

R5:

R5#conf t

R5(config)#inte0/0

R5(config-if)#ipadd 56.56.56.5 255.255.255.0

R5(config-if)#noshut

R5(config-if)#inte0/1

R5(config-if)#ipadd 123.123.123.5 255.255.255.0

R5(config-if)#noshut 

R5(config-if)#end

R5(config)#routerospf 1

R5(config-router)#router-id5.5.5.5

R5(config-router)#net123.123.123.5 0.0.0.0 a 0

R5(config-router)#net56.56.56.0 0.0.0.255 a 2

R5(config-router)#end

R6:

R6#conf t

R6(config)#inte0/0

R6(config-if)#ipadd 56.56.56.6 255.255.255.0

R6(config-if)#noshut

R6(config-if)#inte0/1

R6(config-if)#ipadd 67.67.67.6 255.255.255.0

R6(config-if)#intlo0

R6(config-if)#ipadd 60.6.6.6 255.255.255.0

R6(config-if)#end

R6(config)#routerospf 1

R6(config-router)#router-id6.6.6.6

R6(config-router)#net60.6.6.0 0.0.0.255 a 2

R6(config-router)#net56.56.56.0 0.0.0.255 a 2

R6(config-router)#net67.67.67.0 0.0.0.255 a 3

R6(config-router)#end

R7:

R7#conf t

R7(config)#inte0/1

R7(config-if)#ipadd 67.67.67.7 255.255.255.0

R7(config-if)#noshut

R7(config-if)#intlo 0

R7(config-if)#ipadd 70.7.7.7 255.255.255.0

R1(config-if)#intlo 1

R1(config-if)#ipadd 80.8.8.8 255.255.255.0

R7(config-if)#end

R7(config)#routerospf 1

R7(config-router)#router-id7.7.7.7

R7(config-router)#net70.7.7.0 0.0.0.255 a 3

R7(config-router)#net67.67.67.0 0.0.0.255 a 3

R7(config-router)#end

檢驗鄰居關系

R4#<b>show ip ospf neighbor</b>

NeighborID     Pri   State           Dead

Time   Address         Interface

2.2.2.2           1  FULL/DROTHER    00:00:30    123.123.123.2   Ethernet0/1

3.3.3.3           1  FULL/DROTHER    00:00:35    123.123.123.3   Ethernet0/1

5.5.5.5           1  FULL/DR         00:00:34    123.123.123.5   Ethernet0/1

1.1.1.1           1  FULL/BDR        00:00:35    14.14.14.1      Ethernet0/0

R4#show ip routeospf

     20.0.0.0/32is

subnetted, 1 subnets

O       20.2.2.2[110/11]

via 123.123.123.2, 00:33:28, Ethernet0/1

     10.0.0.0/32

issubnetted, 1 subnets

O       10.1.1.1

[110/11]via 14.14.14.1, 00:33:28, Ethernet0/0

     56.0.0.0/24

is subnetted, 1 subnets

O

IA    56.56.56.0

[110/20] via 123.123.123.5,00:33:28, Ethernet0/1

     60.0.0.0/32

IA    60.6.6.6

[110/21] via 123.123.123.5,00:33:28, Ethernet0/1

2.

環回口改成點到點網絡

<b>由于環回口被視為主機,環回口網絡總被當作主機路由學習</b>

10.0.0.0/32 is subnetted, 1

subnets

O       10.1.1.1[110/11]

via 14.14.14.1, 00:33:28, Ethernet0/0

現在将R1 環回口0 改成點到點網絡

R1#show ip ospf interface loopback 0

Loopback0is up, line protocol is up

  Internet

Address 10.1.1.1/24,Area 1

  Process

ID 1, Router ID 1.1.1.1,Network Type LOOPBACK, Cost: 1

Loopbackinterface is treated as a stub Host

R1#CONF T

R1(config)#intlo 0

R1(config-if)#ipospf network point-to-point

檢驗:

ID 1, Router ID 1.1.1.1,Network Type POINT_TO_POINT, Cost:

1

  Transmit

Delay is 1 sec, StatePOINT_TO_POINT,

  Timer

intervals configured, Hello 10, Dead40, Wait 40, Retransmit

5

    oob-resync

timeout 40

  Supports

Link-local Signaling (LLS)

  Index

1/1, flood queue length 0

  Next

0x0(0)/0x0(0)

  Last

flood scan length is 0, maximum is 0

flood scan time is 0 msec, maximum is 0msec

  Neighbor

Count is 0, Adjacent neighbor countis 0

Suppresshello for 0 neighbor(s)

R4#show ip route ospf

via 123.123.123.2, 00:45:58, Ethernet0/1

     10.0.0.0/24is

O       10.1.1.0[110/11]

via 14.14.14.1, 00:01:39, Ethernet0/0

[110/20] via 123.123.123.5,00:01:39, Ethernet0/1

    60.0.0.0/32

[110/21] via 123.123.123.5,00:01:39, Ethernet0/1

3.

改優先級

由于ospf配置後,先配置的就變為DR,BDR。是以如果先配置R2,R3則R2,R3是DR,BDR

現在要将R5變成DR,R4變為BDR。那麼就是将R2,R3,R4的優先級變為0,放棄DR,BDR競選,然後再将其R4,R3,R2優先級恢複為1.

R2,R3,R4的優先級變為0,放棄DR,BDR競選

R2:

R2(config)#INTE0/1

R2(config-if)#IPOSPF PRI

R2(config-if)#IPOSPF PRIority 0

R3:

R3(config-if)#ipospf priority 0

R4:

R4(config)#inte0/1

R4(config-if)#ipospf priority 0

R4,R3,R2優先級恢複為1.

R4(config-if)#ipospf priority 1

R3(config-if)#ipospf priority 1

R2(config-if)#ipospf priority 1

R2#show ip ospf nei

3.3.3.3           1  2WAY/DROTHER    00:00:37    123.123.123.3   Ethernet0/1

4.4.4.4           1  FULL/BDR        00:00:37    123.123.123.4   Ethernet0/1

5.5.5.5           1  FULL/DR         00:00:32    123.123.123.5   Ethernet0/1

4.ospf

的手動彙總

4.1)區域間手動彙總(隻能在ABR上做)

R4(config)#routerospf

1    //進入ospf

R4(config-router)#area1  range

10.0.0.0 255.0.0.0

驗證:

R5#show ip route ospf

via 123.123.123.2, 01:22:01, Ethernet0/1

O IA 10.0.0.0/8 [110/21]via 123.123.123.4, 00:01:19,

Ethernet0/1

     14.0.0.0/24is

IA    14.14.14.0[110/20]

via 123.123.123.4, 01:22:01, Ethernet0/1

O       60.6.6.6

[110/11] via 56.56.56.6,01:22:01, Ethernet0/0

R6#show ip route ospf

     70.0.0.0/32

O       70.7.7.7

[110/11] via 67.67.67.7,01:23:44, Ethernet0/1

IA    20.2.2.2

[110/21]via 56.56.56.5, 01:23:34, Ethernet0/0

O IA 10.0.0.0/8[110/31] via 56.56.56.5,

00:02:57, Ethernet0/0

     123.0.0.0/24

IA    123.123.123.0

[110/20] via 56.56.56.5,01:23:34, Ethernet0/0

IA    14.14.14.0[110/30]

via 56.56.56.5, 01:23:34, Ethernet0/0

5.ospf

認證

鍊路認證:ABR 與正常

明文:

R1:

R1(config-if)#ipospf

authentication     //啟用明文認證

R1(config-if)#ipospf authentication-key abc123

R4(config-if)#ipospf authentication

R4(config-if)#ipospf authentication-key abc123

密文:

R6(config-if)#ipospf authentication

message-digest

R6(config-if)#ipospf message-digest-key 1 md5

abc

R5(config-if)#ipospf authentication

R5(config-if)#ipospf message-digest-key 1 md5

區域認證:骨幹

R2(config-router)#area0 authentication

R2(config-router)#exit

R2(config-if)#ipospf message-digest-key 2 md5

CHINA

R3(config-router)#area0 authentication

R3(config-router)#ipospf message

R3(config-router)#exit

R3(config-if)#ipospf message-digest-key 2 md5

R4(config-router)#area0 authentication

R4(config-router)#exit

R4(config-if)#ipospf message-digest-key 2 md5

R5(config-router)#area0 authentication

R5(config-router)#exit

R5(config)#inte0/1

R5(config-if)#ipospf message-digest-key 2 md5

<b>區域所有裝置接口參與,除環回口</b>

6.ospf

釋出預設路由更新

R2(config)#router ospf 1

R2(config-router)#default-informationoriginate always

metric 2

現象:

R5#showip route ospf

     20.0.0.0/32

O       20.2.2.2

[110/11] via 123.123.123.2,00:00:33, Ethernet0/1

O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:00:33,

     14.0.0.0/24

IA    14.14.14.0

[110/20] via 123.123.123.4,00:00:33, Ethernet0/1

[110/11] via 56.56.56.6,00:52:03, Ethernet0/0

O*E2 0.0.0.0/0 [110/2] via 123.123.123.2,

00:00:33,Ethernet0/1

7.

孤島區域和區域分割

孤島區域就是沒有通過ABR和骨幹區域相連的正常區域(圖中的area

3)

解決方案:虛電路virtual-link

骨幹區域做鍊路認證,虛電路必須啟動認證

R6(config-router)#area2 virtual-link

5.5.5.5  //虛鍊路配置完成(沒有認證的話)

R6(config-router)#AREA2 virtual-link 5.5.5.5

authentication

message-digest    

R6(config-router)#area2 virtual-link 5.5.5.5

message-digest-key 2 md5 CHINA

R5(config-router)#area2 virtual-link 6.6.6.6

R5(config-router)#AREA2 virtual-link 6.6.6.6

authentication message-digest

測試:

1.R7#ping 10.1.1.1 so 70.7.7.7

2. 

R6#showip ospf neighbor

5.5.5.5           0  FULL/  -           -        56.56.56.5      OSPF_VL1

5.5.5.5           1  FULL/BDR        00:00:34    56.56.56.5      Ethernet0/0

7.7.7.7           1  FULL/DR         00:00:35    67.67.67.7      Ethernet0/1

3.路由表對比

虛拟鍊路前:

R2#show ip route

Codes: C- connected, S - static, R - RIP, M - mobile, B -

BGP

       D

- EIGRP, EX - EIGRP external, O -OSPF, IA - OSPF inter

area

       N1

- OSPF NSSA external type 1, N2 - OSPF NSSA external type

       E1

-OSPF external type 1, E2 - OSPF external type 2

       i

- IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 -

IS-ISlevel-2

       ia

- IS-IS inter area, * - candidatedefault, U - per-user static

route

       o

- ODR, P - periodic downloaded staticroute

Gatewayof last resort is not set

     20.0.0.0/24

C       20.2.2.0

is directly connected,Loopback0

O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:38:57,

[110/20] via 123.123.123.5,00:38:57, Ethernet0/1

C       123.123.123.0

is directly connected,Ethernet0/1

[110/20] via 123.123.123.4,00:38:57, Ethernet0/1

[110/21] via 123.123.123.5,00:38:59, Ethernet0/1

虛拟鍊路後:

IA    70.7.7.7[110/31]

via 123.123.123.5, 00:00:02, Ethernet0/1

     67.0.0.0/24

IA    67.67.67.0[110/30]

O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:00:02,

[110/20] via 123.123.123.5,00:00:02, Ethernet0/1

[110/20] via 123.123.123.4,00:00:04, Ethernet0/1

[110/21] via 123.123.123.5,00:05:40, Ethernet0/1

8.STUB 

NSSA的配置

8.1)将外部路由嵌套入ospf

R7(config)#routerrip

R7(config-router)#version2

R7(config-router)#noauto-summary

R7(config-router)#net80.8.8.0

R7(config-router)#exit

R7(config-router)#redistributerip  subnets

R4(config)#routereigrp 1

R4(config-router)#noauto-summary

R4(config-router)#eigrp router-id 40.4.4.4

R4(config-router)#net90.9.9.0 0.0.0.255

R4(config-router)#redistributeeigrp 1 subnets

R2#show ip rout ospf

IA    70.7.7.7

[110/31] via 123.123.123.5,00:06:45, Ethernet0/1

     80.0.0.0/24

E2    80.8.8.0

[110/20] via 123.123.123.5,00:00:39, Ethernet0/1

IA    67.67.67.0

[110/30] via 123.123.123.5,00:06:45, Ethernet0/1

O IA10.0.0.0/8 [110/21] via 123.123.123.4, 00:06:45,

[110/20] via 123.123.123.5,00:06:45, Ethernet0/1

[110/20] via 123.123.123.4,00:06:45, Ethernet0/1

     90.0.0.0/24

E2    90.9.9.0

[110/21] via 123.123.123.5,00:06:45, Ethernet0/1

8.2)T-STUB:

R4(config-router)#area1 stub no-summary

R1(config-router)#area1 stub

建立前:

R1#showip  rou

ospf

[110/41] via 14.14.14.4, 00:10:18,Ethernet0/0

[110/20] via 14.14.14.4, 00:05:38,Ethernet0/0

[110/21] via 14.14.14.4, 00:10:18,Ethernet0/0

[110/40] via 14.14.14.4,00:10:18, Ethernet0/0

[110/30] via 14.14.14.4,00:10:18, Ethernet0/0

[110/20] via 14.14.14.4,00:10:18, Ethernet0/0

[110/20] via 14.14.14.4, 00:10:18,Ethernet0/0

[110/31] via 14.14.14.4, 00:10:18,Ethernet0/0

O*E2 0.0.0.0/0 [110/2] via 14.14.14.4,

00:10:18,Ethernet0/0

建立後:

R1#show ip route ospf

O*IA 0.0.0.0/0 [110/11] via 14.14.14.4,

00:00:34,Ethernet0/0

8.3)T-NSSA

R5(config-router)#area3 nssa no-summary

R7(config-router)#area2 nssa

————完——

繼續閱讀