第三章 OSPF多区域原理及配置
实验案例一 OSPF邻居的建立
一、实验环境
二、需求描述
1、通过配置不同的故障现象,加深对OSPF邻居状态的理解。
三、实验步骤
(一)配置路由器接口地址和OSPF协议,保证两台路由器之间形成邻接关系。
1、R1的配置
R1(config)# int f0/0
R1(config-if)# ip add 10.0.0.1 255.255.255.0 R1(config-if)# no shutdown
R1(config)# router ospf 1
R1(config-router)# network 0.0.0.0 255.255.255.255 area 0(将本机上的IP网段或IP地址告知邻居交换机,0.0.0.0 255.255.255.255是IP和IP反码,area是区域号)(router-id在ospf中,起到一个表明身份的作用,如果不手工指定的话,
会默认用loopback来作为router-id,如果loopback口没有地址,则用物理接口上最大的ip地址作为router-id,如果连物理地址都没有,路由器会提示你手工指定一个router-id)
2、R2的配置
R2(config)# int f0/0
R2(config-if)# ip add 10.0.0.2 255.255.255.0 R2(config-if)# no shutdown R2(config)# int S1/0
R2(config-if)# ip add 20.0.0.1 255.255.255.0 R2(config-if)# no shutdown
R2(config)# router ospf 1
R21(config-router)# network 0.0.0.0 255.255.255.255 area 0
3、R3的配置
R31(config)# int S0/0
R3(config-if)# ip add 20.0.0.2 255.255.255.0 R3(config-if)# no shutdown
R3(config)# router ospf 1
R3(config-router)# network 0.0.0.0 255.255.255.255 area 0
4、验证
Show ip ospf d d 查看ospf数据库 Show ip ospf nei查看邻居端口情况
(二)更改路由器R1和R2的F0/0接口的HELLO报文参数。 R1(config)# int f0/0
R1(config-if)# ip ospf hello-interval 50
R2(config)# int f0/0
R2(config-if)# ip ospf hello-interval 30
结论:Hello报文的间隔时间不同,不能建立邻接关系。
(三)更改路由器R1和R2的F0/0接口的HELLO时间,使其大于Dead时间。
R1(config)# int f0/0
R1(config-if)# ip ospf hello-interval 50 R1(config-if)# ip ospf dead-interval 40
R2(config)# int f0/0
R2(config-if)# ip ospf hello-interval 50 R2(config-if)# ip ospf dead-interval 40
结论:Hello报文的间隔时间大于Dead时间,不能建立邻接关系
(四)更改路由器R1和R2的F0/0接口优先级,设为0。
R1(config)# int f0/0
R1(config-if)# ip ospf priority 0
R2(config)# int f0/0
R2(config-if)# ip ospf priority 0
结论:以太网相连接口间优先级都设为0,没有DR,所以不能建立邻接关系,邻接状态为2way。
(五)更改路由器R2和R3的串口接口MTU值。
R2(config)# int S1/0
R2(config-if)# MTU 1518
R3(config)# int S0/0 R3(config-if)# MTU 1496
结论:串口上MTU值不同,不能建立邻接关系。
(六)更改路由器R2和R2的串口接口封装类型。
R2(config)# int S1/0
R2(config-if)# encapsulation ppp R3(config)# int S0/0
R3(config-if)# encapsulation hdlc
结论:串口上一个PPP封装,一个是HDLC封装,邻接关系表为空。
实验案例二 OSPF多区域的配置
一、实验环境
二、需求描述
1、使用OSPF实现总公司和各分公司互通,避免由于网段变更导致的重复配置。
三、实验步骤
(一)配置路由器接口地址和loopback接口。
1、R1的配置
R1(config)# int f0/0
R1(config-if)# ip add 10.0.0.9 255.255.255.252 R1(config-if)# no shutdown R1(config)# int f1/0
R1(config-if)# ip add 10.0.0.5 255.255.255.252 R1(config-if)# no shutdown R1(config)# int f2/0
R1(config-if)# ip add 10.0.0.1 255.255.255.252 R1(config-if)# no shutdown R1(config)# int f3/0
R1(config-if)# ip add 192.168.1.1 255.255.255.0
R1(config-if)# no shutdown
R1(config)# int loopback 0(作用是检测和管理路由器) R1(config-if)# ip add 1.1.1.1 255.255.255.255 R1(config-if)# no shutdown
2、R2的配置
R2(config)# int f0/0
R2(config-if)# ip add 10.0.0.2 255.255.255.252 R2(config-if)# no shutdown R2(config)# int f1/0
R2(config-if)# ip add 192.168.2.1 255.255.255.0 R2(config-if)# no shutdown R2(config)# int loopback 0
R2(config-if)# ip add 2.2.2.2 255.255.255.255 R2(config-if)# no shutdown
3、R3的配置
R3(config)# int f0/0
R3(config-if)# ip add 10.0.0.6 255.255.255.252 R3(config-if)# no shutdown R3(config)# int f1/0
R3(config-if)# ip add 192.168.4.1 255.255.255.0 R3(config-if)# no shutdown R3(config)# int loopback 0
R3(config-if)# ip add 3.3.3.3 255.255.255.255 R3(config-if)# no shutdown
3、R4的配置
R4(config)# int f0/0
R4(config-if)# ip add 10.0.0.10 255.255.255.252 R4(config-if)# no shutdown R4(config)# int f1/0
R4(config-if)# ip add 192.168.3.1 255.255.255.0 R4config-if)# no shutdown R4(config)# int loopback 0
R4(config-if)# ip add 4.4.4.4 255.255.255.255 R4(config-if)# no shutdown
(二)配置OSPF协议,实现内部网络互通。 1、R1的配置
R1(config)# router ospf 1
R1(config-router)# router-id 1.1.1.1
R1(config-router)# network 1.1.1.1 0.0.0.0 area 0 R1(config-router)# network 192.168.1.1 0.0.0.0 area 0