拓扑图
1
:
基本配置:
R1,R2 192.168.12.0/24
R2,R3 192.168.23.0/24
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
ip ospf network point-to-point
interface Loopback1
ip address 10.10.10.10 255.255.255.0
ip ospf network point-to-point //
指定
OSPF
网络类型避免
loopback
接口问题
配置参数:
access-list 1 deny 10.10.10.0
access-list 1 permit any
router ospf 1
network 1.1.1.0 0.0.0.255 area 0
network 10.10.10.0 0.0.0.255 area 0
network 192.168.12.0 0.0.0.255 area 0
r1(config-router)#distribute-list 1 out s0/0
% Interface not allowed with OUT for OSPF
r1(config-router)#distribute-list 1 out //
可以看出路由器不允许
OUT
方向的分发列表后接接口,用
network
直接宣告的路由在
OUT
分发列表中无用!!!如下的配置效果:
r2#clea ip rou *
r2#sh ip rou
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O 1.1.1.0 [110/65] via 192.168.12.1, 00:00:01, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O 10.10.10.0 [110/65] via 192.168.12.1, 00:00:01, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/1
r2#
r3#clea ip rou *
r3#sh ip rou
O 192.168.12.0/24 [110/128] via 192.168.23.1, 00:00:01, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O 1.1.1.0 [110/129] via 192.168.23.1, 00:00:01, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O 10.10.10.0 [110/129] via 192.168.23.1, 00:00:01, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0
r3#
拓扑图
2
:
基本配置:
R1,R2 192.168.12.0/24
R2,R3 192.168.23.0/24
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
ip ospf network point-to-point
!
interface Loopback1
ip address 10.10.10.10 255.255.255.0
ip ospf network point-to-point //
指定
OSPF
网络类型避免
loopback
接口问题
router ospf 1
redistribute connected metric 30 subnets
network 192.168.12.0 0.0.0.255 area 0
在这里先查看各路由器的路由表:
r1#sh ip rou
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Loopback1
O 192.168.23.0/24 [110/128] via 192.168.12.2, 00:01:09, Serial0/0
r1#
r2#sh ip rou
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/30] via 192.168.12.1, 00:01:24, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.10.10.0 [110/30] via 192.168.12.1, 00:01:24, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/1
r2#
r3#sh ip rou
O 192.168.12.0/24 [110/128] via 192.168.23.1, 00:01:28, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/30] via 192.168.23.1, 00:01:28, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.10.10.0 [110/30] via 192.168.23.1, 00:01:28, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0
r3#
现在配置分发列表:
R1
:
r1(config)#acc 1 de 10.10.10.0
r1(config)#acc 1 per an
r1(config)#router os 1
r1(config-router)#distribute-list 1 out s0/0
% Interface not allowed with OUT for OSPF
r1(config-router)#distribute-list 1 out
查看配置效果:
r2#clea ip rou *
r2#sh ip rou
C 192.168.12.0/24 is directly connected, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/30] via 192.168.12.1, 00:00:02, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/1
r2#
r3#clea ip route *
r3#sh ip rou
O 192.168.12.0/24 [110/128] via 192.168.23.1, 00:00:01, Serial0/0
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/30] via 192.168.23.1, 00:00:01, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0
r3#
可以看到分发列表在
OSPF
中,只有在重发布到
OSPF
里的路由才是起作用的,对本地始发的路由不起作用,因为本地始发的路由是通过
LSA
来进行路由更新的,重发布是通过路由信息来工作的。
本文转自810105851 51CTO博客,原文链接:http://blog.51cto.com/4708948/1131416
,如需转载请自行联系原作者