拓扑图:
配置
路由基本配置
Router>
Router>
Router>en
Router#conf ter
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host r1
r1(config)#no ip domain lookup
r1(config)#line conso
r1(config)#line console 0
r1(config-line)#exect-tiemou
r1(config-line)#exect-time
r1(config-line)#exec-tim
r1(config-line)#exec-timeout 00
r1(config-line)#log
r1(config-line)#logg
r1(config-line)#logging sync
r1(config-line)#logging synchronous
r1(config-line)#exit
r1(config)#inter s1/1
r1(config-if)#ip address 10.10.10.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#no shutdown
r1(config-if)#exit
r1(config)#inter loopback 1
r1(config-if)#
%LINK-5-CHANGED: Interface Loopback1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback1, changed state to up
r1(config-if)#ip address 172.16.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#inter loop 2
r1(config-if)#
%LINK-5-CHANGED: Interface Loopback2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback2, changed state to up
r1(config-if)#ip address 171.16.2.1 255.255.255.0
r1(config-if)#no shutdown
r1(config-if)#inter loop 1
r1(config-if)#ip address 171.16.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#inter loop 3
r1(config-if)#
%LINK-5-CHANGED: Interface Loopback3, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback3, changed state to up
r1(config-if)#ip address 171.16.3.1 255.255.255.0
r1(config-if)#no shutdown
r1(config-if)#exit
配置单区域ospf路由
r1(config-if)#ip address 171.16.3.1 255.255.255.0
r1(config-if)#no shutdown
r1(config-if)#exit
r1(config)#router os
r1(config)#router ospf a
r1(config)#router ospf ?
<1-65535> Process ID
r1(config)#router ospf 111 ?
<cr>
r1(config)#router ospf 111
r1(config-router)#net
r1(config-router)#network ?
A.B.C.D Network number
r1(config-router)#network 10.10.10.0 0.0.0.255 area ?
<0-4294967295> OSPF area ID as a decimal value
A.B.C.D OSPF area ID in IP address format
r1(config-router)#network 10.10.10.0 0.0.0.255 area 0 ?
<cr>
r1(config-router)#network 10.10.10.0 0.0.0.255 area 0
r1(config-router)#exit
r1(config)#exit
r1#
%SYS-5-CONFIG_I: Configured from console by console
r1#
%LINK-5-CHANGED: Interface Serial1/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/1, changed state to up
r1#
00:15:59: %OSPF-5-ADJCHG: Process 111, Nbr 172.16.3.1 on Serial1/1 from LOADING to FULL, Loading Done
查看路由
-------------R1路由表-------------
r1#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
- candidate default, U - per-user static route, o - ODR
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Serial1/1
20.0.0.0/24 is subnetted, 1 subnets
O 20.20.20.0 [110/128] via 10.10.10.2, 00:03:17, Serial1/1
171.16.0.0/24 is subnetted, 3 subnets
C 171.16.1.0 is directly connected, Loopback1
C 171.16.2.0 is directly connected, Loopback2
C 171.16.3.0 is directly connected, Loopback3
-------------R2路由表-------------
r2#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
- candidate default, U - per-user static route, o - ODR
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Serial1/0
20.0.0.0/24 is subnetted, 1 subnets
C 20.20.20.0 is directly connected, Serial1/1
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.1.0 is directly connected, Loopback1
C 172.16.2.0 is directly connected, Loopback2
C 172.16.3.0 is directly connected, Loopback3
-------------R3路由表-------------
r3#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
- candidate default, U - per-user static route, o - ODR
Gateway of last resort is not set
10.0.0.0/24 is subnetted, 1 subnets
O 10.10.10.0 [110/128] via 20.20.20.1, 00:00:12, Serial1/0
20.0.0.0/24 is subnetted, 1 subnets
C 20.20.20.0 is directly connected, Serial1/0
173.16.0.0/24 is subnetted, 3 subnets
C 173.16.1.0 is directly connected, Loopback1
C 173.16.2.0 is directly connected, Loopback2
C 173.16.3.0 is directly connected, Loopback3
ping测试
-----------r1上ping r3路由------------
r1#ping 173.16.3.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 173.16.3.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
r1#ping 20.20.20.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 20.20.20.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/5/7 ms
-----------r3上ping r1路由------------
r3#ping 10.10.10.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 2/5/7 ms
拓展信息
----查看ospf接口信息-----
r1#show ip ospf interface
Serial1/1 is up, line protocol is up
Internet address is 10.10.10.1/24, Area 0
Process ID 111, Router ID 171.16.3.1, Network Type POINT-TO-POINT, Cost: 64
Transmit Delay is 1 sec, State POINT-TO-POINT, Priority 0
No designated router on this network
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:04
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 1 , Adjacent neighbor count is 1
Adjacent with neighbor 172.16.3.1
Suppress hello for 0 neighbor(s)
----查看ospf数据表------
r1#show ip ospf database
OSPF Router with ID (171.16.3.1) (Process ID 111)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
171.16.3.1 171.16.3.1 1728 0x80000002 0x002c1c 2
172.16.3.1 172.16.3.1 339 0x80000004 0x00b6b3 4
173.16.3.1 173.16.3.1 339 0x80000002 0x00d135 2
-----查看ospf邻居表-----
r1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
172.16.3.1 0 FULL/ - 00:00:33 10.10.10.2 Serial1/1
------查看ospf路由-----
r1#show ip route ospf
20.0.0.0/24 is subnetted, 1 subnets
O 20.20.20.0 [110/128] via 10.10.10.2, 00:09:35, Serial1/1
原文地址:http://blog.51cto.com/vbers/2169157