ospf命令


https://blog.51cto.com/sweetpotato/1410762

 

1、配置步驟

1、配置loopback接口地址: //用於產生路由器的Router ID
Router(config)#interface loopback 0
Router(config-if)#ip address IP地址 掩碼

2、啟動OSPF路由進程: //本路由器的進程號,用於標識同一路由器上的多個OSPF進程
Router(config)#router ospf 進程號

3、指定OSPF協議運行的接口和所在區域:
Router(config-router)#network 網絡號 反向掩碼 area 區域號
/*說明:
**網絡號:可以是網絡地址、子網地址、接口地址
**反向掩碼:即子網掩碼的反碼(例如:192.168.2.0/28的反向掩碼為:0.0.0.15<-->因為子網掩碼為255.255.255.240,所以反向掩碼為:0.0.0.<255-240=15>)
**區域號:指明網絡所屬區域,此處是0-->骨干區域(非0則為常規區域;單區域必須為骨干區域哈)
*/

2、修改接口的cost值:

//修改接口的cost值(OSPF路由器在接口上使用cost值來決定最佳路徑,cost=10^8/BW)
Router(config-if)#ip ospf cost number

//舉例:
Router(config)#inteface s0
Router(config-if)#ip ospf cost 1000 //取值范圍1~65535

3、配置OSPF計時器:

//配置OSPF計時器(為了交換信息,相鄰路由器必須有相同的hello和dead間隔,通常dead時間是hello時間的4倍)
Router(config-if)#ip ospf hello-interval 時間(s)
Router(config-if)#ip ospf dead-interval 時間(s)

4、Router ID的配置命令:

Router(config)#router ospf 進程號 //啟用OSPF
Router(config-router)#router-id IP_Address //指定Router-ID

5、OSPF匯總命令:

Router(config-router)#area 區域號 range 要匯總的IP 掩碼

6、驗證OSPF配置:

//驗證OSPF配置:
//查看鄰居表
Router#show ip ospf neighbor
//查看鏈路狀態數據庫
Router#show ip ospf database
//查看路由表
Router#show ip route
//查看OSPF的配置
Router#show ip ospf
//查看OSPF接口數據結構
Router#show ip ospf interface 接口
Router#show ip ospf interface brief
//查看配置文件中有關OSPF的配置信息
Router#show running-config | s r o

 

mpls2# show ip ospf
 OSPF Routing Process, Router ID: 192.168.122.164
 Supports only single TOS (TOS0) routes
 This implementation conforms to RFC2328
 RFC1583Compatibility flag is disabled
 OpaqueCapability flag is disabled
 Initial SPF scheduling delay 0 millisec(s)
 Minimum hold time between consecutive SPFs 50 millisec(s)
 Maximum hold time between consecutive SPFs 5000 millisec(s)
 Hold time multiplier is currently 1
 SPF algorithm last executed 4.165s ago
 Last SPF duration 129 usecs
 SPF timer is inactive
 LSA minimum interval 5000 msecs
 LSA minimum arrival 1000 msecs
 Write Multiplier set to 20 
 Refresh timer 10 secs
 This router is an ASBR (injecting external routing information)
 Number of external LSA 8. Checksum Sum 0x000230b6
 Number of opaque AS LSA 0. Checksum Sum 0x00000000
 Number of areas attached to this router: 1
 Area ID: 0.0.0.0 (Backbone)
   Number of interfaces in this area: Total: 4, Active: 4
   Number of fully adjacent neighbors in this area: 1
   Area has no authentication
   SPF algorithm executed 16654 times
   Number of LSA 3
   Number of router LSA 3. Checksum Sum 0x000101db
   Number of network LSA 0. Checksum Sum 0x00000000
   Number of summary LSA 0. Checksum Sum 0x00000000
   Number of ASBR summary LSA 0. Checksum Sum 0x00000000
   Number of NSSA LSA 0. Checksum Sum 0x00000000
   Number of opaque link LSA 0. Checksum Sum 0x00000000
   Number of opaque area LSA 0. Checksum Sum 0x00000000


mpls2# show ip ospf interface brief
No such interface name

mpls2# show ip ospf interface enp1s0 brief
% Unknown command: show ip ospf interface enp1s0 brief
mpls2# show ip ospf interface enp1s0 json 
{
  "interfaces":{
    "enp1s0":{
      "ifUp":true,
      "ifIndex":2,
      "mtuBytes":1500,
      "bandwidthMbit":4294967295,
      "ifFlags":"<UP,BROADCAST,RUNNING,MULTICAST>",
      "ospfEnabled":true,
      "ipAddress":"192.168.123.164",
      "ipAddressPrefixlen":24,
      "ospfIfType":"Broadcast",
      "localIfUsed":"192.168.123.255",
      "area":"0.0.0.0",
      "routerId":"192.168.122.164",
      "networkType":"BROADCAST",
      "cost":1,
      "transmitDelaySecs":1,
      "state":"DR",
      "priority":1,
      "mcastMemberOspfAllRouters":true,
      "mcastMemberOspfDesignatedRouters":true,
      "timerMsecs":10000,
      "timerDeadSecs":40,
      "timerWaitSecs":40,
      "timerRetransmitSecs":5,
      "timerHelloInMsecs":7648,
      "nbrCount":0,
      "nbrAdjacentCount":0
    }
  }
}
mpls2# show ip ospf neighbor

Neighbor ID     Pri State           Dead Time Address         Interface                        RXmtL RqstL DBsmL
192.168.122.198   1 Full/DROther      36.806s 192.168.1.3     enp6s0:192.168.1.4                   3     0     0
192.168.122.35    1 ExStart/DROther   36.238s 192.168.2.5     enp5s0:192.168.2.4                   0     0     0

mpls2# show ip ospf database

       OSPF Router with ID (192.168.122.164)

                Router Link States (Area 0.0.0.0)

Link ID         ADV Router      Age  Seq#       CkSum  Link count
192.168.122.35  192.168.122.35    12 0x800038bf 0x7ac1 2
192.168.122.164 192.168.122.164    6 0x80006449 0xcae1 4
192.168.122.198 192.168.122.198   11 0x80002079 0x7543 3

                AS External Link States

Link ID         ADV Router      Age  Seq#       CkSum  Route
172.19.2.0      192.168.122.35  1532 0x8000002b 0x5f6c E2 172.19.2.0/24 [0x0]
172.19.2.0      192.168.122.198 1057 0x8000002c 0x879f E2 172.19.2.0/24 [0x0]
192.168.1.3     192.168.122.164 1396 0x80000034 0x296c E2 192.168.1.3/32 [0x0]
192.168.1.4     192.168.122.198 1017 0x8000002d 0x6019 E2 192.168.1.4/32 [0x0]
192.168.2.4     192.168.122.35   872 0x8000002d 0x2bf0 E2 192.168.2.4/32 [0x0]
192.168.2.5     192.168.122.164 1516 0x80000034 0x0a88 E2 192.168.2.5/32 [0x0]
192.168.122.0   192.168.122.164 3600 0x80000026 0x2b02 E2 192.168.122.0/24 [0x0]
192.168.122.0   192.168.122.198 3600 0x80000026 0x5eac E2 192.168.122.0/24 [0x0]


mpls2# show ip ospf route
============ OSPF network routing table ============
N    4.4.4.4/32            [10] area: 0.0.0.0
                           directly attached to lo1
N    192.168.123.0/24      [1] area: 0.0.0.0
                           directly attached to enp1s0

============ OSPF router routing table =============

============ OSPF external routing table ===========


mpls2# show ip ospf route

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM