相信大家看到更多的是在思科设备上的配置,之前我也在思科的设备上做过不少路由的实验,最近有机会接触华为的整套路由和交换设备,于是也做了一些实验。下面和大家分享分享。



拓扑:3台路由器AR-281台交换机



<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />

ospf单区域实验实验分析与体会 ospf单区域配置实验心得_OSPF




步骤:



1.       配置路由器的接口IP地址(包括物理接口和Loopback口,其中Loopback口用来模拟主机)


# 配置Router A:


[Router A] interface ethernet 0/0


[Router A-Ethernet0/0] ip address 192.168.1.1 255.255.255.0


[Router A-Ethernet0/0] quit





[Router A] interface loopback 0


[Router A-LoopBack0] ip address 192.168.31.11 255.255.255.255


//使用32位子网掩码,把Loopback0当作是一台主机





[Router A-LoopBack0] quit








# 配置Router B:


[Router B] interface ethernet 0/0


[Router B-Ethernet0/0] ip address 192.168.1.2 255.255.255.0


[Router B-Ethernet0/0] quit





[Router B] interface loopback 0


[Router B-LoopBack0] ip address 192.168.31.22 255.255.255.255


//使用32位子网掩码,把Loopback0当作是一台主机





[Router B-LoopBack0] quit





# 配置Router C:


[Router C] interface ethernet 0/0


[Router C-Ethernet0/0] ip address 192.168.1.3 255.255.255.0


[Router C-Ethernet0/0] quit





[Router C] interface loopback 0


[Router C-LoopBack0] ip address 192.168.31.33 255.255.255.255


//使用32位子网掩码,把Loopback0当作是一台主机





[Router C-LoopBack0] quit




2.       开启OSPF进程,发布相应的网段


[Router A] ospf 1 router id 192.168.1.1    //手工配置Router-ID


[Router A-ospf-1] area 0


[Router A-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255


[Router A-ospf-1-area-0.0.0.0] network 192.168.31.11 0.0.0.0





[Router B] ospf 1 router id 192.168.1.2    //手工配置Router-ID


[Router B-ospf-1] area 0


[Router B-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255


[Router B-ospf-1-area-0.0.0.0] network 192.168.31.22 0.0.0.0





[Router C] ospf 1 router id 192.168.1.3    //手工配置Router-ID


[Router C-ospf-1] area 0


[Router C-ospf-1-area-0.0.0.0] network 192.168.1.0 0.0.0.255


[Router C-ospf-1-area-0.0.0.0] network 192.168.31.33 0.0.0.0








3.       查看路由表

[RouterA]display ip routing-table

 Routing Table: public net

Destination/Mask   Protocol Pre  Cost        Nexthop         Interface

127.0.0.0/8        DIRECT   0    0           127.0.0.1       InLoopBack0

127.0.0.1/32       DIRECT   0    0           127.0.0.1       InLoopBack0

192.168.1.0/24     DIRECT   0    0           192.168.1.1     Ethernet0/0

192.168.1.1/32     DIRECT   0    0           127.0.0.1       InLoopBack0

192.168.31.11/32   DIRECT   0    0           127.0.0.1       InLoopBack0

192.168.31.22/32   OSPF     10   2           192.168.1.2     Ethernet0/0


192.168.31.33/32   OSPF     10   2           192.168.1.3     Ethernet0/0


//说明学习到了邻居发布的主机路由






4.       使用Ping命令验证连通性


[RouterA]ping 192.168.31.22

  PING 192.168.31.22: 56  data bytes, press CTRL_C to break

    Reply from 192.168.31.22: bytes=56 Sequence=1 ttl=255 time=1 ms

    Reply from 192.168.31.22: bytes=56 Sequence=2 ttl=255 time=2 ms

    Reply from 192.168.31.22: bytes=56 Sequence=3 ttl=255 time=1 ms

    Reply from 192.168.31.22: bytes=56 Sequence=4 ttl=255 time=2 ms

    Reply from 192.168.31.22: bytes=56 Sequence=5 ttl=255 time=2 ms




  --- 192.168.31.22 ping statistics ---

    5 packet(s) transmitted

    5 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 1/1/2 ms




[RouterA]ping 192.168.31.33

  PING 192.168.31.33: 56  data bytes, press CTRL_C to break

    Reply from 192.168.31.33: bytes=56 Sequence=1 ttl=255 time=2 ms

    Reply from 192.168.31.33: bytes=56 Sequence=2 ttl=255 time=2 ms

    Reply from 192.168.31.33: bytes=56 Sequence=3 ttl=255 time=2 ms

    Reply from 192.168.31.33: bytes=56 Sequence=4 ttl=255 time=2 ms

    Reply from 192.168.31.33: bytes=56 Sequence=5 ttl=255 time=2 ms




  --- 192.168.31.33 ping statistics ---

    5 packet(s) transmitted

    5 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 2/2/2 ms

//验证成功,可以ping通邻居的loopback口





5.       具体配置信息

< RouterA >display current-configuration

#

 sysname RouterA

#

interface Ethernet0/0

 ip address 192.168.1.1 255.255.255.0

#

interface LoopBack0

 ip address 192.168.31.11 255.255.255.255

#

ospf 1 router-id 192.168.1.1


 area 0.0.0.0


  network 192.168.1.0 0.0.0.255


  network 192.168.31.11 0.0.0.0





< RouterB>display current-configuration

#

 sysname RouterB

#

interface Ethernet0/0

 ip address 192.168.1.2 255.255.255.0

#

interface LoopBack0

 ip address 192.168.31.22 255.255.255.255

#

ospf 1 router-id 192.168.1.2


 area 0.0.0.0


  network 192.168.1.0  0.0.0.255


  network 192.168.31.22  0.0.0.0





< RouterC>display current-configuration

#

 sysname RouterC

#

interface Ethernet0/0

 ip address 192.168.1.3 255.255.255.0

#

interface LoopBack0

 ip address 192.168.31.33 255.255.255.255

#

ospf 1 router-id 192.168.1.3


 area 0.0.0.0


  network 192.168.1.0  0.0.0.255


  network 192.168.31.33  0.0.0.0





[RouterA]display ospf ?

  brief             General information about OSPF routing processes

  interface         OSPF interface information

  lsdb              Details of the OSPF database

  peer              OSPF neighbor lis




*************

[RouterA]display ospf brief     //查看正在运行的OSPF进程的简要信息




 Router ID 192.168.1.1

                       OSPF Protocol Information




 RouterID: 192.168.1.1

 Spf-schedule-interval: 5

 Routing preference: Inter/Intra: 10 External: 150

 Default ASE parameters: Metric: 1 Tag: 1 Type: 2

 SPF computation count: 3

 Area Count: 1    Nssa Area Count: 0




 Area 0.0.0.0:          //区域0

   Authtype: none   Flags: <>

   SPF scheduled: <Router Net>

   Interface: 192.168.31.11 (LoopBack0) --> 192.168.31.11

 PtoP    Type: PointToPoint            //loopback0配置的是点对点类型

     Priority: 1

     Timers: Hello 10, Dead 40, Poll 40, Retransmit 5, Transmit Delay 1




   Interface: 192.168.1.1 (Ethernet0/0)

 DROther    Type: Broadcast  //DROther表明自身既不是DR,也不是BDR

 //默认优先级

 //DR的Router-ID

 //BDR的Router-ID

     Timers: Hello 10, Dead 40, Poll 40, Retransmit 5, Transmit Delay 1

//从上面的输出信息可以知道本台路由器的身份以及谁是DR/BDR




[RouterA]display ospf lsdb                          //显示链路状态数据库的信息




                OSPF Process 1 with Router ID 192.168.1.1

                         Link State Database




                        Area: 0.0.0.0

Type LinkState ID    AdvRouter        Age Len  Sequence   Metric Where

Stub 192.168.31.11   192.168.1.1       37 24   0               0 SpfTree

Stub 192.168.31.22   192.168.1.2       40 24   0               0 SpfTree


Stub 192.168.31.33   192.168.1.3       40 24   0               0 SpfTree


Rtr  192.168.1.1     192.168.1.1       37 48   80000008        0 SpfTree

Rtr  192.168.1.2     192.168.1.2       41 48   80000007        0 Clist

Rtr  192.168.1.3     192.168.1.3       41 48   80000007        0 Clist

Net  192.168.1.3     192.168.1.3       41 36   80000002        0 SpfTree




//红色部分标记的条目是从邻居收到的链路状态信息




[RouterA]display ospf peer      //显示OSPF邻居的信息

                OSPF Process 1 with Router ID 192.168.1.1

                               Neighbors




 192.168.1.1(Ethernet0/0)'s neighbor(s)   //从e0/0口建立的邻居关系


//以下是邻居的状态信息

  RouterID: 192.168.1.2     Address: 192.168.1.2   

 Priority: 1

        DR: 192.168.1.3  BDR: 192.168.1.2

        Dead timer expires in 31s

        Neighbor has been up for 00:00:49   




  RouterID: 192.168.1.3     Address: 192.168.1.3   

 Priority: 1

        DR: 192.168.1.3  BDR: 192.168.1.2

        Dead timer expires in 34s

        Neighbor has been up for 00:00:57




 [RouterA]display ospf routing //显示OSPF路由协议学习到的路由

                OSPF Process 1 with Router ID 192.168.1.1

                             Routing Tables




Routing for Network

Destination             Cost Type NextHop         AdvRouter        Area

192.168.31.11/32           1 Stub 192.168.31.11   192.168.1.1      0.0.0.0

192.168.1.0/24             1 Net  192.168.1.1     192.168.1.3      0.0.0.0

192.168.31.22/32           2 Stub 192.168.1.2     192.168.1.2      0.0.0.0

192.168.31.33/32           2 Stub 192.168.1.3     192.168.1.3      0.0.0.0




Total Nets: 4

  Intra Area: 4  Inter Area: 0  ASE: 0  NSSA: 0







[RouterA]display ospf interface //显示参与OSPF进程的路由器接口




                OSPF Process 1 with Router ID 192.168.1.1

                               Interfaces




  Area: 0.0.0.0       

      IP Address      Type  State    Cost Pri DR              BDR

 PtoP     1    1   None            None

 DROther  1    1   192.168.1.3     192.168.1.2




//其中192.168.1.1对应的是接口e0/0,192.168.31.11对应的是接口loopback0








总结:在这个简单的拓扑上配置单区域OSPF是比较简单的,写这篇文章的目的是让初学者对OSPF有一个初步的认识,帮助他们分析在书本上学到的理论,另外还可以给一些对华为路由器设备感兴趣的同志们了解了解,对比华为路由器和思科路由器在命令上的区别。




转载于:https://blog.51cto.com/170810/91824