目录
OSPF单区域配置
Silent-Interface
OSPF多区域配置
调整OSPF Cost值
OSPF特殊区域
OSPF报文认证
内容
OSPF单区域配置
网络拓扑
配置要求
把R1、R2配置到一个OSPF Area中实现网段互通。
配置代码
R1
interface GigabitEthernet 0/0/0
ip address 172.16.1.254 255.255.255.0
interface GigabitEthernet 0/0/1
ip address 172.16.2.254 255.255.255.0
interface GigabitEthernet 0/0/2
ip address 172.17.12.1 255.255.255.252
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
network 172.17.12.0 0.0.0.3
R2
interface GigabitEthernet 0/0/2
ip address 172.17.12.2 255.255.255.252
interface Loopback0
ospf network-type broadcast
ip address 172.16.255.2 255.255.255.0
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 172.17.12.0 0.0.0.3
network 172.16.255.0 0.0.0.255
Silent-Interface
网络拓扑
同上
配置要求
使R1不要向PC所在的网络中发送OSPF报文。
配置代码
R1
ospf 1 router-id 1.1.1.1
silent-interface GigabitEthernet 0/0/0
silent-interface GigabitEthernet 0/0/1
OSPF多区域配置
网络拓扑
配置要求
按照网络拓扑所示配置OSPF多区域实现区域互联。
配置代码
R1
interface Ethernet 0/0/0
ip address 172.16.1.254 255.255.255.0
interface Ethernet 0/0/1
ip address 172.16.2.254 255.255.255.0
interface GigabitEthernet 0/0/1
ip address 172.16.0.1 255.255.255.252
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 172.16.0.0 0.0.0.3
area 0.0.0.1
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
R2
interface Ethernet 0/0/0
ip address 172.16.9.254 255.255.255.0
interface Ethernet 0/0/1
ip address 172.16.10.254 255.255.255.0
interface GigabitEthernet 0/0/1
ip address 172.16.0.5 255.255.255.252
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 172.16.0.4 0.0.0.0.3
area 0.0.0.2
network 172.16.9.0 0.0.0.255
network 172.16.10.0 0.0.0.255
CORE
interface GigabitEthernet 0/0/1
ip address 172.16.0.2 255.255.255.252
interface GigabitEthernet 0/0/2
ip address 172.16.0.6 255.255.255.252
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 172.16.0.0 0.0.0.3
network 172.16.0.4 0.0.0.3
调整OSPF Cost值
网络拓扑
配置要求
使R3在转发到192.168.100.0/24的流量以R1为主路,R2为备份。
配置代码
R1
interface Ethernet 0/0/0
ip address 192.168.100.1 255.255.255.0
interface Ethernet 0/0/1
ip address 192.168.0.2 255.255.255.253
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 192.168.100.0 0.0.0.255
network 192.168.0.2 0.0.0.3
R2
interface Ethernet 0/0/0
ip address 192.168.100.3 255.255.255.0
interface Ethernet 0/0/1
ip address 192.168.0.6 255.255.255.252
#
ospf router-id 2.2.2.2
area 0.0.0.0
network 192.168.100.0 0.0.0.255
network 192.168.0.4 0.0.0.3
R3
interface Ethernet 0/0/0
ip address 192.168.0.1 255.255.255.252
interface Ethernet 0/0/1
ip address 192.168.0.5 255.255.255.252
ospf cost 100
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 192.168.0.0 0.0.0.3
network 192.168.0.4 0.0.0.3
R4
interface Ethernet 0/0/0
ip address 192.168.100.4 255.255.255.0
#
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 192.168.100.0 0.0.0.255
OSPF特殊区域
网络拓扑
配置要求
分别配置验证OSPF特殊区域。
配置代码
OSPF网络互联
R1
interface GigabitEthernet 0/0/0
ip address 10.1.12.1 255.255.255.0
#
ospf 1 router-id 1.1.1.1
area 0.0.0.1
network 10.1.12.0 0.0.0.255
R2
interface GigabitEthernet 0/0/0
ip address 10.1.12.2 255.255.255.0
interface GigabitEthernet 0/0/1
ip address 10.1.23.2 255.255.255.0
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 10.1.23.0 0.0.0.255
area 0.0.0.1
network 10.1.12.0 0.0.0.255
R3
interface GigabitEthernet 0/0/0
ip address 10.1.23.3 255.255.255.0
#
ospf 1 router-id 3.3.3.3
import-route static
area 0.0.0.0
network 10.1.23.0 0.0.0.255
#
ip route-static 10.3.1.0 255.255.255.0 NULL0
ip route-static 10.3.2.0 255.255.255.0 NULL0
修改Area1为Stub Area(阻挡ASBR Summary LSA、ASE LSA)
#在所有处于Stub Area的路由器上声明该区域属于Stub
R1 | R2
ospf 1
area 1
stub
修改Area1为Totally Stub Area(阻挡Network Summary LSA、ASBR Summary LSA、ASE LSA)
R1 | R2
ospf 1
area 1
stub no-summary
修改Area1为NSSA并引入少量路由(阻挡ASBR Summary LSA、ASE LSA)
R1 | R2
ospf 1
area 1
undo stub
nssa
R1
ip route-static 10.1.1.0 24 NULL0
#
ospf 1
import-static route
修改Area1为Totally NSSA(阻挡Network Summary LSA、ASBR Summary LSA、ASE LSA)
R1 | R2
ospf 1
area 1
nssa no-summary
OSPF报文认证
网络拓扑
配置要求
按照网络拓扑所示把网络互联,在Area 0中使用区域认证,在Area1中使用接口认证。
配置代码
R1
R2
R3
R4
参考文献
[1] HCNP路由交换学习指南