配置单区域OSPF

 

R1#conf  t 

R1(conf ig)#int loopback 0 //配置环回接口,环回接口的IP将会被当做router id

R1(conf ig-if)#ip add 1.1.1.1 255.255.255.255

R1(conf ig)# int f0/0 

R1(conf ig-if)ip add 192.168.1.1 255.255.255.0

R1(conf ig-if)#no shutdown

R1(conf ig-if)#int f0/1

R1(conf ig-if)#ip add 200.0.2.1 255.255.255.0

R1(conf ig-if)#no shutdown

R1(conf ig-if)#int f1/0

R1(conf ig-if)#ip add 200.0.3.2 255.255.255.0

R1(conf ig-if)#no shutsown

R1(config)#router ospf 100 //进程号,基于本地

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.255 area 0 //反码指定IP地址范围

R1(config-router)#network 200.0.2.1 0.0.0.255 area 0//area 代表区域

R1(config-router)#200.0.3.2 0.0.0.255 area 0

R2R3R4配置类似

四个路由的ospf进程号必须相同

环回接口的IP子网掩码配置255.255.255.255代表该地址为主机地址

Show命令:

Show ip protocols

Show ip route

Show ip ospf

Show ip ospf  interface f0/0

Show ip ospf  neighbor //显示接口的ospf邻居信息  

 

 


 

 

Ospf 配置负载均衡:

R(conf ig-router)#maximum-paths <1-16>//默认为4,负载均衡的路径最大条数

更改链路的开销以确保路径等价于负载均衡

R(conf ig-if) #ip ospf cost <1-65535>

配置ospf口令身份验证:

接口模式下

R1(conf ig-if)#ip ospf authentication [message-digest  |  null]//明文加密、MD5加密、无身份验证

R1(conf ig-if)#ip ospf authentication-key password //用于连接此接口邻居路由器的口令

两个路由器所接的接口身份验证类型必须相同且密码相同,才能交换ospf信息。

实验总结:

Router-id

1.若未配置换回接口,路由器将选择所有接口中IP地址最大的一个当做router id

2.可以使用router-id命令手动设置

3.配置环回接口(逻辑存在),ospf会选择环回接口的IP地址当做router-id,环回接口必须在开始配置,若交换机已经选择router-id,配置环回接口后router-id不会改变,必须重新启动路由或ospf才会生效。

计算ospf开销的公式:开销=参考带宽 接口带宽(单位为b/s)