设置命令passive-interface后接口将不在建立邻居关系,也不再发送和接收路由信息。
R1的配置:
interface Loopback1
ip address 1.1.1.1 255.255.255.255
!
interface Loopback2
ip address 1.1.2.1 255.255.255.255
!
interface Serial1/1
ip address 10.0.1.1 255.255.255.0
serial restart-delay 0
!
router ospf 1
router-id 1.1.1.1 //设置路由器ID
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0 //宣告直连网络
network 1.1.2.0 0.0.0.255 area 0
network 10.0.1.0 0.0.0.255 area 0
R2的配置:
interface Loopback1
ip address 2.2.2.2 255.255.255.255
!
interface Serial1/0
ip address 10.0.1.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 10.0.2.1 255.255.255.0
serial restart-delay 0
!
router ospf 1
router-id 2.2.2.2 //设置路由器ID
log-adjacency-changes
network 2.2.2.0 0.0.0.255 area 0
network 10.0.1.0 0.0.0.255 area 0
network 10.0.2.0 0.0.0.255 area 0
!
R3的配置:
interface Loopback1
ip address 3.3.3.3 255.255.255.255
!
interface Serial1/0
ip address 10.0.2.2 255.255.255.0
serial restart-delay 0
!
router ospf 1
log-adjacency-changes
network 10.0.2.0 0.0.0.255 area 0
network 3.3.3.0 0.0.0.255 area 0
!
上述基本命令配置完成后查看R3的路由表和R1的邻居关系如下:
R3#show ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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, 2 subnets
O 1.1.1.1 [110/129] via 10.0.2.1, 00:00:02, Serial1/0
O 1.1.2.1 [110/129] via 10.0.2.1, 00:00:02, Serial1/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 10.0.2.1, 00:00:02, Serial1/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback1
10.0.0.0/24 is subnetted, 2 subnets
C 10.0.2.0 is directly connected, Serial1/0
O 10.0.1.0 [110/128] via 10.0.2.1, 00:00:02, Serial1/0
OSPF网络中的所有路由都学到了
R1#show ip ospf neighbors //查看R1的邻居
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:38 10.0.1.2 Serial1/1
在路由器R1上配置如下命令:
R1(config)#router ospf 1
R1(config-router)#passive-interface s1/1
再次查看R3的路由表如下:
R3#show ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 10.0.2.1, 00:00:02, Serial1/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback1
10.0.0.0/24 is subnetted, 2 subnets
C 10.0.2.0 is directly connected, Serial1/0
O 10.0.1.0 [110/128] via 10.0.2.1, 00:00:02, Serial1/0
1.1.1.0 和 1.1.2.0路由条目不见了,R1的邻居也没了。