OSPF(Open Shortest Path First开放式最短路径优先)[1]是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。与RIP相比,OSPF是链路状态路由协议,而RIP是距离矢量路由协议。OSPF的协议管理距离(AD)是110。
RIP(路由信息协议)是一种在网关与主机之间交换路由选择信息的标准。RIP 是一种内部网关协议。在国家性网络中如当前的因特网,拥有很多用于整个网络的路由选择协议。作为形成网络的每一个自治系统,都有属于自己的路由选择技术,不同的 AS 系统,路由选择技术也不同。
OSPF 的DR筛选过程
1.优先级为0的不参与选举;
2.优先级高的路由器为DR;
3.优先级相同时,以router ID 大为DR;router ID 以回环接口中最大ip为准;若无回环接口,以真实接口最大ip为准。
4.缺省条件下,优先级为1。
OSPF与RIP相互导入路由,重点的配置是在三层交换机上面配置OSPF时导入rip;然后配置RIP的时候导入ospf,没有什么太复杂的地方;如下图
三层交换机Switch0的主要配置: (重点的配置)
interface Loopback0
ip address 1.1.1.1 255.0.0.0
!
interface FastEthernet0/1
no switchport
ip address 192.168.1.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/2
no switchport
ip address 192.168.3.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/3
no switchport
ip address 192.168.0.1 255.255.255.0
duplex auto
speed auto
!
.....
.....
router ospf 100
router-id 1.1.1.1
log-adjacency-changes
redistribute rip metric 1 subnets
network 192.168.1.0 0.0.0.255 area 0
network 192.168.3.0 0.0.0.255 area 0
network 192.168.0.0 0.0.0.255 area 1
!
router rip
redistribute ospf 100 metric 1
network 192.168.0.0
!
-----------------------------------------------------
router2的主要配置:
!
interface FastEthernet0/0
ip address 192.168.10.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.0.2 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router rip
network 192.168.0.0
network 192.168.10.0
!
---------------------------------------------------------------
router3的主要配置:
!
interface Loopback0
ip address 2.2.2.2 255.0.0.0
!
interface FastEthernet0/0
ip address 192.168.4.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.1.2 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router ospf 100
router-id 2.2.2.2
log-adjacency-changes
network 192.168.1.0 0.0.0.255 area 0
network 192.168.4.0 0.0.0.255 area 0
!
ip classless
!
!
---------------------------------------------------------------
router0的主要配置:
!
interface Loopback0
ip address 3.3.3.3 255.0.0.0
!
interface FastEthernet0/0
ip address 192.168.4.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.3.2 255.255.255.0
duplex auto
speed auto
!
interface Vlan1
no ip address
shutdown
!
router ospf 100
router-id 3.3.3.3
log-adjacency-changes
network 192.168.3.0 0.0.0.255 area 0
network 192.168.4.0 0.0.0.255 area 0
!
ip classless
!
!
---------------------------------------------------------------
router1的主要配置:
!
interface Loopback0
ip address 4.4.4.4 255.0.0.0
!
interface Loopback1
no ip address
!
interface Loopback10 #增加了一个网段6.0
ip address 192.168.6.1 255.255.255.0
!
interface FastEthernet0/0
ip address 192.168.4.3 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Vlan1
no ip address
shutdown
!
router ospf 100
router-id 4.4.4.4
log-adjacency-changes
network 192.168.4.0 0.0.0.255 area 0
network 192.168.6.0 0.0.0.255 area 2
!
ip classless
!
!
---------------------------------------------------------------
Switch0的主要配置:只是把端口打开了
***********************************************
看看DR和BDR
可以看出:2.2.2.2 是指定路由(DR);1.1.1.1、3.3.3.3是备份指定路由(BDR)
若2.2.2.2出现故障,测3.3.3.3会成为DR!
转载于:https://blog.51cto.com/jk409/787559