|
步骤: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] quit2. 开启OSPF进程,发布相应的网段[Router A] ospf 1 router>
[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>[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>[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.03. 查看路由表[RouterA]display ip routing-table Routing Table: public netDestination/Mask Protocol Pre Cost 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命令验证连通性[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进程的简要信息 OSPF Process 1 with Router> 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 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/BDR[RouterA]display 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 SpfTreeRtr 192.168.1.1 192.168.1.1 37 48 80000008 0 SpfTreeRtr 192.168.1.2 192.168.1.2 41 48 80000007 0 ClistRtr 192.168.1.3 192.168.1.3 41 48 80000007 0 ClistNet 192.168.1.3 192.168.1.3 41 36 80000002 0 SpfTree//红色部分标记的条目是从邻居收到的链路状态信息[RouterA]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: Full Mode: Nbr is Master 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 State: Full Mode: Nbr is Master 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> 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 Net 192.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: 4 Intra Area: 4 Inter Area: 0 ASE: 0 NSSA: 0[RouterA]display ospf interface //显示参与OSPF进程的路由器接口 OSPF Process 1 with Router> Interfaces Area: 0.0.0.0 IP Address Type State Cost Pri DR BDR 192.168.31.11 PtoP PtoP 1 1 None None 192.168.1.1 Bcast DROther 1 1 192.168.1.3 192.168.1.2//其中192.168.1.1对应的是接口e0/0,192.168.31.11对应的是接口loopback0总结:在这个简单的拓扑上配置单区域OSPF是比较简单的,写这篇文章的目的是让初学者对OSPF有一个初步的认识,帮助他们分析在书本上学到的理论,另外还可以给一些对华为路由器设备感兴趣的同志们了解了解,对比华为路由器和思科路由器在命令上的区别。 |
|
|