网络结构为四个路器与一个交换机直连,在单区域内配置OSPF:
路由器一:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname router1
router1(config)#int f0/0
router1(config-if)#ip add 192.168.1.1 255.255.255.0
router1(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
router1(config-if)#ip ospf priority 100
router1(config-if)#exit
router1(config)#router ospf 1
router1(config-router)#network 192.168.1.0 0.0.0.255 area 0
router1(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
router1#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
router1#
路由器2:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname router2
router2(config)#int f0/0
router2(config-if)#ip add 192.168.1.2 255.255.255.0
router2(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
router2(config-if)#exit
router2(config)#router ospf 2
router2(config-router)#network 192.168.1.0 0.0.0.255 area 0
router2(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
router2#copy running-config
00:11:15: %OSPF-5-ADJCHG: Process 2, Nbr 192.168.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
% Incomplete command.
router2#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
router2#
路由器3:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname router3
router3(config)#int f0/0
router3(config-if)#ip add 192.168.1.3 255.255.255.0
router3(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
router3(config-if)#ip ospf priority 150
router3(config-if)#exit
router3(config)#router ospf 3
router3(config-router)#network 192.168.1.0 0.0.0.255 area 0
router3(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
router3#
00:14:16: %OSPF-5-ADJCHG: Process 3, Nbr 192.168.1.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
router3#copy running
00:14:24: %OSPF-5-ADJCHG: Process 3, Nbr 192.168.1.1 on FastEthernet0/0 from EXCHANGE to FULL, Exchange Done
% Incomplete command.
router3#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
router3#
路由器4:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname router4
router4(config)#int f0/0
router4(config-if)#ip add 192.168.1.4 255.255.255.0
router4(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
router4(config-if)#ip ospf priority 0
router4(config-if)#exit
router4(config)#router ospf 4
router4(config-router)#network 192.168.1.0 0.0.0.255 area 0
router4(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
router4#
00:18:05: %OSPF-5-ADJCHG: Process 4, Nbr 192.168.1.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
00:18:05: %OSPF-5-ADJCHG: Process 4, Nbr 192.168.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
router4#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
router4#
测试结果:
router1#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/53/63 ms
router1#ping 192.168.1.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/56/63 ms
router1#ping 192.168.1.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/56/79 ms
router1#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/53/63 ms
router1#ping 192.168.1.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/56/63 ms
router1#ping 192.168.1.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/56/79 ms
查看OSPF信息:
router1#sh ip ospf neighbor detail
 Neighbor 192.168.1.2, interface address 192.168.1.2
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 1, State is FULL, 6 state changes
    DR is 192.168.1.3 BDR is 192.168.1.1
    Options is 0x00
    Dead timer due in 00:00:39
    Neighbor is up for 00:02:00
    Index 1/1, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 0
    Last retransmission scan time is 0 msec, maximum is 0 msec
 Neighbor 192.168.1.3, interface address 192.168.1.3
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 150, State is FULL, 5 state changes
    DR is 192.168.1.3 BDR is 192.168.1.1
    Options is 0x00
    Dead timer due in 00:00:31
    Neighbor is up for 00:01:58
    Index 2/2, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 0
    Last retransmission scan time is 0 msec, maximum is 0 msec
 Neighbor 192.168.1.4, interface address 192.168.1.4
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 0, State is FULL, 6 state changes
    DR is 192.168.1.3 BDR is 192.168.1.1
    Options is 0x00
    Dead timer due in 00:00:35
    Neighbor is up for 00:01:54
    Index 3/3, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 0
    Last retransmission scan time is 0 msec, maximum is 0 msec
router1#
查看端品:
router1#sh ip ospf int
FastEthernet0/0 is up, line protocol is up
  Internet address is 192.168.1.1/24, Area 0
  Process ID 1, Router ID 192.168.1.1, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State BDR, Priority 100
  Designated Router (ID) 192.168.1.3, Interface address 192.168.1.3
  Backup Designated Router (ID) 192.168.1.1, Interface address 192.168.1.1
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:06
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 3, Adjacent neighbor count is 3
    Adjacent with neighbor 192.168.1.2
    Adjacent with neighbor 192.168.1.3  (Designated Router)
    Adjacent with neighbor 192.168.1.4
  Suppress hello for 0 neighbor(s)
测试结果OK****************************^--^