R1基本配置
interface Loopback0
ip address 172.16.1.1 255.255.255.0
!
interface Loopback1
ip address 172.16.2.1 255.255.255.0
!
interface Loopback2
ip address 10.1.1.1 255.255.255.0
interface FastEthernet1/0
ip address 200.1.1.1 255.255.255.0
no shutdown
router ospf 1
network 10.1.1.0 0.0.0.255 area 10
network 172.16.1.0 0.0.0.255 area 10
network 172.16.2.0 0.0.0.255 area 10
network 200.1.1.0 0.0.0.255 area 0
R2的基本配置
interface Ethernet0/0
ip address 200.1.2.1 255.255.255.0
no shutdown
interface FastEthernet1/0
ip address 200.1.1.2 255.255.255.0
no shutdown
router ospf 1
network 200.1.1.0 0.0.0.255 area 0
network 200.1.2.0 0.0.0.255 area 0
R3基本配置
interface Loopback0
ip address 192.168.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 200.1.2.2 255.255.255.0
no shutdown
router ospf 1
network 192.168.1.0 0.0.0.255 area 0
network 200.1.2.0 0.0.0.255 area 0
R2上配置分发列表路由过滤
第一步创建需要控制的路由;
access-list 10 deny 172.16.1.0 0.0.0.255
access-list 10 permit any
第二步应用分发列表调用10号列表
router ospf 1
distribute-list 10 in FastEthernet1/0
在R2查看路由信息,看不到172.16.1.0的路由
R2#show ip route
C 200.1.1.0/24 is directly connected, FastEthernet1/0
C 200.1.2.0/24 is directly connected, Ethernet0/0
172.16.0.0/32 is subnetted, 1 subnets
O IA 172.16.2.1 [110/2] via 200.1.1.1, 00:08:15, FastEthernet1/0
10.0.0.0/32 is subnetted, 1 subnets
O IA 10.1.1.1 [110/2] via 200.1.1.1, 00:08:15, FastEthernet1/0
192.168.1.0/32 is subnetted, 1 subnets
O 192.168.1.1 [110/11] via 200.1.2.2, 00:08:15, Ethernet0/0
R2#
在R3查看路由信息,可以看到172.16.1.0的路由,
R3#show ip route
O 200.1.1.0/24 [110/11] via 200.1.2.1, 00:09:09, Ethernet0/0
C 200.1.2.0/24 is directly connected, Ethernet0/0
172.16.0.0/32 is subnetted, 2 subnets
O IA 172.16.1.1 [110/12] via 200.1.2.1, 00:09:09, Ethernet0/0
O IA 172.16.2.1 [110/12] via 200.1.2.1, 00:09:09, Ethernet0/0
10.0.0.0/32 is subnetted, 1 subnets
O IA 10.1.1.1 [110/12] via 200.1.2.1, 00:09:09, Ethernet0/0
C 192.168.1.0/24 is directly connected, Loopback0
结论:
说明了OSPF的分发列表应用的IN方向是由本地数据库到路由表的方向,R3和其他路由器的链路状态数据库是同步FULL状态的。