多区域的OSPF配置
通过默认路由指向环回接口LO 0模拟Internet,并且将默认路由注入到OSPF区域。
 
Router 0的配置:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int serial 0/0
Router(config-if)#ip add 12.12.12.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
 
%LINK-5-CHANGED: Interface Serial0/0, changed state to down
Router(config-if)#exit
Router(config)#int loopback 0
 
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 1.1.1.1 255.255.255.0
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface Serial0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
Router(config-if)#exit
Router(config)#ip route 0.0.0.0 0.0.0.0 loopback 0
Router(config)#router ospf 1
Router(config-router)#network 12.12.12.0 0.0.0.255 area 1
Router(config-router)#network 1.1.1.0 0.0.0.255 area 1
Router(config-router)#default-information ?
  originate  Distribute a default route
Router(config-router)#default-information originate
Router(config-router)#end
Router#
Router#ping 12.12.12.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.12.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/6 ms
 
Router#ping 3.3.3.3
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 5/8/12 ms
 
Router#ping 23.23.23.2
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 23.23.23.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/7/10 ms
 
Router#show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is 0.0.0.0 to network 0.0.0.0
 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/65] via 12.12.12.2, 00:00:58, Serial0/0
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/129] via 12.12.12.2, 00:00:58, Serial0/0
     4.0.0.0/32 is subnetted, 1 subnets
O IA    4.4.4.4 [110/193] via 12.12.12.2, 00:00:48, Serial0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.12.12.0 is directly connected, Serial0/0
     23.0.0.0/24 is subnetted, 1 subnets
O IA    23.23.23.0 [110/128] via 12.12.12.2, 00:00:58, Serial0/0
     34.0.0.0/24 is subnetted, 1 subnets
O IA    34.34.34.0 [110/192] via 12.12.12.2, 00:00:48, Serial0/0
S*   0.0.0.0/0 is directly connected, Loopback0
Router#
%LINK-5-CHANGED: Interface Serial0/0, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
00:41:37: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Serial0/0 from FULL to Down: Interface down or detached
%LINK-5-CHANGED: Interface Serial0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
00:41:59: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Serial0/0 from EXCHANGE to FULL, Exchange Done
Router#ping 34.34.34.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 34.34.34.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/9/10 ms
 
Router#
 
Router 1的配置;
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int serial 0/0
Router(config-if)#ip add 12.12.12.2 255.255.255.0
Router(config-if)#no shut
 
%LINK-5-CHANGED: Interface Serial0/0, changed state to up
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
Router(config-if)#exit
Router(config)#int s0/1
Router(config-if)#ip add 23.23.23.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface Serial0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
Router(config-if)#exit
Router(config)#int loopback 0
 
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 2.2.2.2 255.255.255.0
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#router ospf 1
Router(config-router)#network 12.12.12.0 0.0.0.255 area 1
00:10:01: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on Serial0/0 from LOADING to FULL, Loading Done
Router(config-router)#network 23.23.23.0 0.0.0.255 area 0
Router(config-router)#network 2.2.2.0 0.0.0.255 area 0
Router(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
Router#clear ip route *
Router#debug ip ospf adj
OSPF adjacency events debugging is on
 
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
00:00:10: OSPF: Build router LSA for area 1, router ID 2.2.2.2, seq 0x80000001
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
00:00:12: OSPF: Build router LSA for area 0, router ID 2.2.2.2, seq 0x80000002
00:00:20: OSPF: Send DBD to 1.1.1.1 on Serial0/0 seq 0x47d3 opt 0x00 flag 0x7 len 32
00:00:20: OSPF: Rcv DBD from 1.1.1.1 on Serial0/0 seq 0x4c1c opt 0x00 flag 0x7 len 32  mtu 1500 state EXSTART
00:00:20: OSPF: First DBD and we are not SLAVE
00:00:20: OSPF: Rcv DBD from 1.1.1.1 on Serial0/0 seq 0x47d3 opt 0x00 flag 0x2 len 192  mtu 1500 state EXSTART
00:00:20: OSPF: NBR Negotiation Done. We are the MASTER
00:00:20: OSPF: Send DBD to 1.1.1.1 on Serial0/0 seq 0x47d4 opt 0x00 flag 0x3 len 52
00:00:20: OSPF: Rcv DBD from 1.1.1.1 on Serial0/0 seq 0x47d4 opt 0x00 flag 0x0 len 32  mtu 1500 state EXCHANGE
00:00:20: OSPF: Send DBD to 1.1.1.1 on Serial0/0 seq 0x47d5 opt 0x00 flag 0x1 len 32
00:00:20: OSPF: Rcv DBD from 1.1.1.1 on Serial0/0 seq 0x47d5 opt 0x00 flag 0x0 len 32  mtu 1500 state EXCHANGE
00:00:20: Exchange Done with 1.1.1.1 on Serial0/0
00:00:20: OSPF: Database request to 1.1.1.1
00:00:20: OSPF: sent LS REQ packet to 12.12.12.1, length 84
00:00:20: OSPF: Rcv DBD from 1.1.1.1 on Serial0/0 seq 0x47d5 opt 0x00 flag 0x0 len 32  mtu 1500 state LOADING
00:00:20: Synchronized with with 1.1.1.1 on Serial0/0, state FULL
00:00:20: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on Serial0/0 from LOADING to FULL, Loading Done
00:00:20: OSPF: Build router LSA for area 1, router ID 2.2.2.2, seq 0x80000002
00:00:22: OSPF: Send DBD to 3.3.3.3 on Serial0/1 seq 0x20c4 opt 0x00 flag 0x7 len 32
00:00:22: OSPF: Rcv DBD from 3.3.3.3 on Serial0/1 seq 0x4da8 opt 0x00 flag 0x7 len 32  mtu 1500 state EXSTART
00:00:22: OSPF: NBR Negotiation Done. We are the SLAVE
00:00:22: OSPF: Send DBD to 3.3.3.3 on Serial0/1 seq 0x4da8 opt 0x00 flag 0x2 len 52
00:00:22: OSPF: Rcv DBD from 3.3.3.3 on Serial0/1 seq 0x4da9 opt 0x00 flag 0x3 len 172  mtu 1500 state EXCHANGE
00:00:22: OSPF: Send DBD to 3.3.3.3 on Serial0/1 seq 0x4da9 opt 0x00 flag 0x0 len 32
00:00:22: OSPF: Rcv DBD from 3.3.3.3 on Serial0/1 seq 0x4daa opt 0x00 flag 0x1 len 32  mtu 1500 state EXCHANGE
00:00:22: OSPF: Send DBD to 3.3.3.3 on Serial0/1 seq 0x4daa opt 0x00 flag 0x0 len 32
00:00:22: Exchange Done with 3.3.3.3 on Serial0/1
00:00:22: OSPF: Database request to 3.3.3.3
00:00:22: OSPF: sent LS REQ packet to 23.23.23.2, length 72
00:00:22: OSPF: Send DBD to 3.3.3.3 on Serial0/1 seq 0x4daa opt 0x00 flag 0x0 len 32
00:00:22: Synchronized with with 3.3.3.3 on Serial0/1, state FULL
00:00:22: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on Serial0/1 from LOADING to FULL, Loading Done
00:00:22: OSPF: Build router LSA for area 0, router ID 2.2.2.2, seq 0x80000003
 
Router>
00:00:25: OSPF: Build summary LSA for area 1, router ID 2.2.2.2, seq 0x80000001
00:00:25: OSPF: Build summary LSA for area 0, router ID 2.2.2.2, seq 0x80000001^Z
Router>
Router>
00:00:30: OSPF: Build summary LSA for area 1, router ID 2.2.2.2, seq 0x80000001
00:00:30: OSPF: Build summary LSA for area 0, router ID 2.2.2.2, seq 0x80000003^Z
Router>en
Router#no
00:00:35: OSPF: Build summary LSA for area 1, router ID 2.2.2.2, seq 0x80000004
00:00:35: OSPF: Build summary LSA for area 0, router ID 2.2.2.2, seq 0x80000005d
Router#
00:00:40: OSPF: Build summary LSA for area 1, router ID 2.2.2.2, seq 0x80000004
00:00:40: OSPF: Build summary LSA for area 0, router ID 2.2.2.2, seq 0x80000007no
Router#no debu
Router#no debug
00:00:50: OSPF: end of Wait on interface Serial0/0
00:00:50: OSPF: Build summary LSA for area 1, router ID 2.2.2.2, seq 0x80000004
00:00:50: OSPF: Build summary LSA for area 0, router ID 2.2.2.2, seq 0x80000009o
Router#no debug o
Router#no debug
00:00:52: OSPF: end of Wait on interface Serial0/1?
  all          Enable all debugging
  eigrp        EIGRP Protocol information
  frame-relay  Frame Relay
  ip           IP information
  ppp          PPP (Point to Point Protocol) information
Router#no debug ip o
Router#no debug ip ospf adj
OSPF adjacency events debugging is off
Router#
 
Router 2的配置;
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int s0/0
Router(config-if)#ip add 34.34.34.1 255.255.255.0
Router(config-if)#clock rate 64000
Router(config-if)#no shut
 
%LINK-5-CHANGED: Interface Serial0/0, changed state to down
Router(config-if)#exit
Router(config)#int serial 0/1
Router(config-if)#ip add 23.23.23.2 255.255.255.0
Router(config-if)#no shut
 
%LINK-5-CHANGED: Interface Serial0/1, changed state to up
Router(config-if)#exit
Router(config)#int loopback 0
 
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 3.3.3.3 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#router ospf 1
Router(config-router)#network 23.23.23.0 0.0.0.255 area 0
Router(config-router)#network 3.3.3.0 0.0.0.255 area 0
Router(config-router)#network 34.34.34.0 0.0.0.255 area 2
Router(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
Router#show ip rou
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is not set
 
     1.0.0.0/32 is subnetted, 1 subnets
O IA    1.1.1.1 [110/129] via 23.23.23.1, 00:21:45, Serial0/1
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 23.23.23.1, 00:17:18, Serial0/1
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 34.34.34.2, 00:07:35, Serial0/0
     12.0.0.0/24 is subnetted, 1 subnets
O IA    12.12.12.0 [110/128] via 23.23.23.1, 00:22:05, Serial0/1
     23.0.0.0/24 is subnetted, 1 subnets
C       23.23.23.0 is directly connected, Serial0/1
     34.0.0.0/24 is subnetted, 1 subnets
C       34.34.34.0 is directly connected, Serial0/0
Router#
 
Router 4的配置:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#int s0/0
Router(config-if)#ip add 34.34.34.2 255.255.255.0
Router(config-if)#no shut
 
%LINK-5-CHANGED: Interface Serial0/0, changed state to up
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
Router(config-if)#exit
Router(config)#int loopback 0
 
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
Router(config-if)#ip add 4.4.4.4 255.255.255.0
Router(config-if)#no shut
Router(config-if)#exit
Router(config)#router ospf 1
Router(config-router)#network 34.34.34.0 0.0.0.255 area 2
Router(config-router)#network 4.4.4.0 0.0.0.255 area 2
Router(config-router)#end
Router#show ip rou
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is not set
 
     1.0.0.0/32 is subnetted, 1 subnets
O IA    1.1.1.1 [110/193] via 34.34.34.1, 00:08:09, Serial0/0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/129] via 34.34.34.1, 00:08:09, Serial0/0
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/65] via 34.34.34.1, 00:08:09, Serial0/0
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     12.0.0.0/24 is subnetted, 1 subnets
O IA    12.12.12.0 [110/192] via 34.34.34.1, 00:08:09, Serial0/0
     23.0.0.0/24 is subnetted, 1 subnets
O IA    23.23.23.0 [110/128] via 34.34.34.1, 00:08:09, Serial0/0
     34.0.0.0/24 is subnetted, 1 subnets
C       34.34.34.0 is directly connected, Serial0/0
Router#ping 12.12.12.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.12.12.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 9/13/16 ms
 
Router#