TOPO如下:

基本配置如下
:
l
R1
l
R2
l
R3
R1基本配置
|
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 123.1.1.1 255.255.255.0
!
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 123.1.1.0 0.0.0.255 area 0
|
R2基本配置
|
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Ethernet0/0
ip address 123.1.1.2 255.255.255.0
!
router ospf 10
router-id 2.2.2.2
log-adjacency-changes
network 2.2.2.0 0.0.0.255 area 0
network 123.1.1.0 0.0.0.255 area 0
|
R3基本配置
|
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Ethernet0/0
ip address 123.1.1.3 255.255.255.0
!
router ospf 10
router-id 3.3.3.3
log-adjacency-changes
network 3.3.3.0 0.0.0.255 area 0
network 123.1.1.0 0.0.0.255 area 0
|
网络类型:广播
工作方式
| 是否要选DR/BDR
| 是否要指定邻居
| 邻居形成快慢
|
点到点
| 否
| 否
| 不能形成邻居
|
广播(默认)
| 是
| 否
| 较快,7秒左右
|
NBMA
| 是
| 是
| 很慢,1分47秒
不知道是不是人品问题
|
点到多点
| 否
| 否
| 较快,7秒左右
|
点到多点非广播
| 否
| 是
| 快
|
测试⑴:广播(默认)
查看端口的工作模式:
r1#sho ip os int
Ethernet0/0 is up, line protocol is up
Internet Address 123.1.1.1/24, Area 0
Process ID 10, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State DROTHER, Priority 1
Designated Router (ID) 3.3.3.3, Interface address 123.1.1.3
Backup Designated router (ID) 2.2.2.2, Interface address 123.1.1.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5(以下忽略)
查看邻居关系:有DR/BDR选举
r1# sho ip os nei
Neighbor ID
Pri
State
Dead Time
Address
Interface
2.2.2.2
1
FULL/BDR
00:00:39
123.1.1.2
Ethernet0/0
3.3.3.3
1
FULL/DR
00:00:32
123.1.1.3
Ethernet0/0
测试⑵:点到点
在R1、R2、R3上修改端口的工作模式为point-to-point
r1(config-if)#ip os network point-to-point
r2(config-if)#ip os network point-to-point
r3(config-if)#ip os network point-to-point
做完以上配置之后,我们发现R1一会儿和R2形成邻居,一会儿又想和R3形成邻居关系:(debug消息如下:因为R2先起来,邻居关系在路由器缓存里面有个快照,所以R1和R2形成邻居时非常快,R3又想过来抢,导致R1和R2的邻居关系down,在R1和R3还未来得及形成邻居时,R2又过来抢,由于有邻居关系的快照,很快就形成了,但是不能保持很久又被R3抢了)
*Mar 28 07:34:44.951: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on Ethernet0/0 from LOADING to FULL, Loading Done
r1(config-if)#
*Mar 28 07:34:49.939: %OSPF-4-NONEIGHBOR: Received database description from unknown neighbor 3.3.3.3
r1(config-if)#
*Mar 28 07:34:51.691: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Adjacency forced to reset
r1(config-if)#
*Mar 28 07:34:53.783: %OSPF-5-ADJCHG: Process 10, Nbr 3.3.3.3 on Ethernet0/0 from INIT to DOWN, Neighbor Down: Adjacency forced to reset
*Mar 28 07:34:54.939: %OSPF-4-NONEIGHBOR: Received database description from unknown neighbor 3.3.3.3
r1(config-if)#
*Mar 28 07:34:54.959: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on Ethernet0/0 from LOADING to FULL, Loading Done
r1(config-if)#
*Mar 28 07:34:59.939: %OSPF-4-NONEIGHBOR: Received database description from unknown neighbor 3.3.3.3
r1(config-if)#
*Mar 28 07:35:01.691: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on Ethernet0/0 from FULL to DOWN, Neighbor Down: Adjacency forced to reset
r1(config-if)#
*Mar 28 07:35:03.783: %OSPF-5-ADJCHG: Process 10, Nbr 3.3.3.3 on Ethernet0/0 from EXSTART to DOWN, Neighbor Down: Adjacency forced to reset
*Mar 28 07:35:04.943: %OSPF-4-NONEIGHBOR: Received database description from unknown neighbor 3.3.3.3
r1(config-if)#
*Mar 28 07:35:04.959: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on Ethernet0/0 from LOADING to FULL, Loading Done(以下忽略)
查看邻居关系:
R1总是在与其他两台形成邻居关系
测试⑶:NBMA
在R1、R2、R3上修改端口的工作模式并在R1上指定邻居(如果没有手动指定邻居,邻居关系起不来,邻居只要在一边指定)
r1(config-if)#ip os net non-broadcast
r1(config-if)#router os 10
r1(config-router)#nei 123.1.1.2
r1(config-router)#nei 123.1.1.2
r2(config-if)#ip os net non-broadcast
r3(config-if)#ip os net non-broadcast
查看端口工作模式
r1#sho ip os int
Ethernet0/0 is up, line protocol is up
Internet Address 123.1.1.1/24, Area 0
Process ID 10, Router ID 1.1.1.1, Network Type NON_BROADCAST, Cost: 64
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 1.1.1.1, Interface address 12.1.1.1
Backup Designated router (ID) 2.2.2.2, Interface address 12.1.1.2
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
(以下忽略)
查看邻居关系:有DR/BDR选举
r1#sho ip os nei
Neighbor ID
Pri
State
Dead Time
Address
Interface
2.2.2.2
1
FULL/DROTHER
00:01:36
123.1.1.2
Ethernet0/0
3.3.3.3
1
FULL/DR
00:01:46
123.1.1.3
Ethernet0/0
测试⑷:点到多点
在R1、R2、R3上修改端口的工作模式
R1(config-if)#ip ospf network point-to-multipoint
R2(config-if)#ip ospf network point-to-multipoint
R3(config-if)#ip ospf network point-to-multipoint
查看端口工作模式:
r1#sho ip os int
Ethernet0/0 is up, line protocol is up
Internet Address 12.1.1.1/24, Area 0
Process ID 10, Router ID 1.1.1.1, Network Type POINT_TO_MULTIPOINT, Cost: 64
Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT,
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
(以下忽略)
查看邻居关系:没有DR/BDR选举
r1#sh ip os nei
Neighbor ID
Pri
State
Dead Time
Address
Interface
2.2.2.2
0
FULL/
-
00:01:58
123.1.1.2
Ethernet0/0
3.3.3.3
0
FULL/
-
00:01:37
123.1.1.3
Ethernet0/0
测试⑸:点到多点非广播
在R1、R2、R3上修改端口的工作模式并在R1上指定邻居(如果没有手动指定邻居,邻居关系起不来,邻居只要在一边指定)
r1(config-if)#ip os network point-to-multipoint non-broadcast
r1(config)#router os 10
r1(config-router)#nei 123.1.1.2
r1(config-router)#nei 123.1.1.3
r2(config-if)#ip os network point-to-multipoint non-broadcast
r3(config-if)#ip os network point-to-multipoint non-broadcast
查看端口工作模式:注意,这里我们配置了点到多点非广播,但是查看端口时只显示点到多点
r2#sho ip os int
Ethernet0/0 is up, line protocol is up
Internet Address 123.1.1.2/24, Area 0
Process ID 10, Router ID 2.2.2.2, Network Type POINT_TO_MULTIPOINT, Cost: 64
Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT,
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
查看邻居关系:没有DR/BDR选举
r1#sho ip os nei
Neighbor ID
Pri
State
Dead Time
Address
Interface
3.3.3.3
0
FULL/
-
00:01:42
123.1.1.3
Ethernet0/0
2.2.2.2
0
FULL/
-
00:01:42
123.1.1.2
Ethernet0/0
总结:在广播型网络类型中,ospf接口的5种工作方式有4种能形成邻居,在形成邻居关系的时间上有所差异,还有一种不能形成邻居。