crespo09 发表于 2018-7-25 09:24:01

在华为路由器上配置单区域OSPF

  步骤:1.       配置路由器的接口IP地址(包括物理接口和Loopback口,其中Loopback口用来模拟主机)# 配置Router A: interface ethernet 0/0 ip address 192.168.1.1 255.255.255.0 quit interface loopback 0 ip address 192.168.31.11 255.255.255.255//使用32位子网掩码,把Loopback0当作是一台主机 quit# 配置Router B: interface ethernet 0/0 ip address 192.168.1.2 255.255.255.0 quit interface loopback 0 ip address 192.168.31.22 255.255.255.255//使用32位子网掩码,把Loopback0当作是一台主机 quit# 配置Router C: interface ethernet 0/0 ip address 192.168.1.3 255.255.255.0 quit interface loopback 0 ip address 192.168.31.33 255.255.255.255//使用32位子网掩码,把Loopback0当作是一台主机 quit2.       开启OSPF进程,发布相应的网段 ospf 1 router>
area 0 network 192.168.1.0 0.0.0.255 network 192.168.31.11 0.0.0.0 ospf 1 router> area 0 network 192.168.1.0 0.0.0.255 network 192.168.31.22 0.0.0.0 ospf 1 router> area 0 network 192.168.1.0 0.0.0.255 network 192.168.31.33 0.0.0.03.       查看路由表display ip routing-tableRouting Table: public netDestination/Mask   Protocol PreCost      Nexthop         Interface127.0.0.0/8      DIRECT   0    0         127.0.0.1       InLoopBack0127.0.0.1/32       DIRECT   0    0         127.0.0.1       InLoopBack0192.168.1.0/24   DIRECT   0    0         192.168.1.1   Ethernet0/0192.168.1.1/32   DIRECT   0    0         127.0.0.1       InLoopBack0192.168.31.11/32   DIRECT   0    0         127.0.0.1       InLoopBack0192.168.31.22/32   OSPF   10   2         192.168.1.2   Ethernet0/0192.168.31.33/32   OSPF   10   2         192.168.1.3   Ethernet0/0//说明学习到了邻居发布的主机路由4.       使用Ping命令验证连通性ping 192.168.31.22PING 192.168.31.22: 56data 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 msping 192.168.31.33PING 192.168.31.33: 56data 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.0network 192.168.1.0 0.0.0.255network 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.0network 192.168.1.00.0.0.255network 192.168.31.220.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.0network 192.168.1.00.0.0.255network 192.168.31.330.0.0.0display ospf ?brief             General information about OSPF routing processesinterface         OSPF interface informationlsdb            Details of the OSPF databasepeer            OSPF neighbor lis*************display ospf brief   //查看正在运行的OSPF进程的简要信息                OSPF Process 1 with Router>                     OSPF Protocol InformationRouterID: 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   Cost: 1 State: 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)   Cost: 1 State: DROther    Type: Broadcast//DROther表明自身既不是DR,也不是BDR   Priority: 1       //默认优先级   Designated Router: 192.168.1.3            //DR的Router-ID   Backup Designated Router: 192.168.1.2      //BDR的Router-ID   Timers: Hello 10, Dead 40, Poll 40, Retransmit 5, Transmit Delay 1//从上面的输出信息可以知道本台路由器的身份以及谁是DR/BDRdisplay ospf lsdb                        //显示链路状态数据库的信息                OSPF Process 1 with Router>                         Link State Database                        Area: 0.0.0.0Type LinkState>Stub 192.168.31.11   192.168.1.1       37 24   0               0 SpfTreeStub 192.168.31.22   192.168.1.2       40 24   0               0 SpfTreeStub 192.168.31.33   192.168.1.3       40 24   0               0 SpfTreeRtr192.168.1.1   192.168.1.1       37 48   80000008      0 SpfTreeRtr192.168.1.2   192.168.1.2       41 48   80000007      0 ClistRtr192.168.1.3   192.168.1.3       41 48   80000007      0 ClistNet192.168.1.3   192.168.1.3       41 36   80000002      0 SpfTree//红色部分标记的条目是从邻居收到的链路状态信息display ospf peer      //显示OSPF邻居的信息                OSPF Process 1 with Router>                               Neighbors   Area 0.0.0.0 interface 192.168.1.1(Ethernet0/0)'s neighbor(s)   //从e0/0口建立的邻居关系//以下是邻居的状态信息RouterID: 192.168.1.2   Address: 192.168.1.2            State: FullMode: Nbr is MasterPriority: 1      DR: 192.168.1.3BDR: 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            State: FullMode: Nbr is MasterPriority: 1      DR: 192.168.1.3BDR: 192.168.1.2      Dead timer expires in 34s      Neighbor has been up for 00:00:57 display ospf routing //显示OSPF路由协议学习到的路由                OSPF Process 1 with Router>                           Routing Tables Routing for Network Destination             Cost Type NextHop         AdvRouter      Area192.168.31.11/32         1 Stub 192.168.31.11   192.168.1.1      0.0.0.0192.168.1.0/24             1 Net192.168.1.1   192.168.1.3      0.0.0.0192.168.31.22/32         2 Stub 192.168.1.2   192.168.1.2      0.0.0.0192.168.31.33/32         2 Stub 192.168.1.3   192.168.1.3      0.0.0.0Total Nets: 4Intra Area: 4Inter Area: 0ASE: 0NSSA: 0display ospf interface //显示参与OSPF进程的路由器接口                OSPF Process 1 with Router>                               Interfaces   Area: 0.0.0.0            IP Address      TypeState    Cost Pri DR            BDR      192.168.31.11   PtoPPtoP   1    1   None            None      192.168.1.1   Bcast DROther1    1   192.168.1.3   192.168.1.2//其中192.168.1.1对应的是接口e0/0,192.168.31.11对应的是接口loopback0总结:在这个简单的拓扑上配置单区域OSPF是比较简单的,写这篇文章的目的是让初学者对OSPF有一个初步的认识,帮助他们分析在书本上学到的理论,另外还可以给一些对华为路由器设备感兴趣的同志们了解了解,对比华为路由器和思科路由器在命令上的区别。
页: [1]
查看完整版本: 在华为路由器上配置单区域OSPF