OSPF动态路由协议

一、OSPF实验拓扑

在这里插入图片描述

基础配置

# 配置ip地址,必须配环回接口

#配置ospf
方式一
R1(config)#router ospf 1
R1(config-router)#network 1.0.0.0 0.0.0.255 area 0
方式二
R2(config)#int range e0/0-1,lo0
R2(config-if-range)#ip ospf 1 area 0

R1:

int range e0/0,lo0
ip ospf 1 area 0

R2:

int range e0/0-1,lo0
ip ospf 1 area 0

R3:

int range e0/0,lo0
ip ospf 1 area 0

管理距离

在这里插入图片描述
R1:

int e0/0
ip address 192.168.12.1 255.255.255.0
no sh
int e0/1
ip addr 192.168.14.1 255.255.255.0
no sh
int lo0
ip add 1.1.1.1 255.255.255.255

router rip
ver 2
network 192.168.12.0
network 1.1.1.1

int range e0/1,lo0
ip ospf 1 area 0

R2:

int e0/0
ip add 192.168.12.2 255.255.255.0
no sh
int e0/1
ip add 192.168.23.2 255.255.255.0
no sh
int lo0
ip add 2.2.2.2 255.255.255.255

router rip
ver 2
network 192.168.12.0
network 192.168.23.0
network 2.2.2.2

R3:

int e0/0
ip add 192.168.23.3 255.255.255.0
no sh
int e0/1
ip addr 192.168.34.3 255.255.255.0
no sh
int lo0
ip add 3.3.3.3 255.255.255.255

router rip
ver 2
network 192.168.23.0
network 3.3.3.3

int range e0/1,lo0
ip ospf 1 area 0

R4:

int e0/0
ip add 192.168.14.4 255.255.255.0
no sh
int e0/1
ip add 192.168.34.4 255.255.255.0
no sh
int lo0
ip add 4.4.4.4 255.255.255.255

int range lo0,e0/0-1
ip ospf 1 area 0
R3#show ip route
Codes: 	L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
		D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
		N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
		E1 - OSPF external type 1, E2 - OSPF external type 2
		i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
		ia - IS-IS inter area, * - candidate default, U - per-user static route
		o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
		a - application route
		+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set
		
		1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
R 		1.0.0.0/8 [120/2] via 192.168.23.2, 00:00:19, Ethernet0/0
O 		1.1.1.1/32 [110/21] via 192.168.34.4, 00:00:21, Ethernet0/1
......

R3#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.34.4 5 msec 6 msec 5 msec
  2 192.168.14.1 1 msec * 1 msec

可以看到在两个路由表都可以去1.1.1.1的时候,选择了匹配更精确的那一条,这里是因为最长匹配原则
所以在
R 	1.0.0.0/8
O 	1.1.1.1/32
两个路由中选择了下面一条,但是我们是要为了验证管理距离对于选路的影响,所以可以关闭rip协议的自动汇总,再重启一下接口,更新路由表,可以看到更新完成后,只有一条路由表
R3#show ip route
Codes: 	L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
		D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
		N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
		E1 - OSPF external type 1, E2 - OSPF external type 2
		i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
		ia - IS-IS inter area, * - candidate default, U - per-user static route
		o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
		a - application route
		+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

		1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/21] via 192.168.34.4, 00:08:08, Ethernet0/1
.......
R3#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.34.4 1 msec 1 msec 0 msec
  2 192.168.14.1 0 msec * 1 msec
最终选择了管理距离短的ospf协议的路径

OSPF简介

  • OSPF(Open Shortest Path First,开放最短路径优先)是一种链路状态路由协议,无路由循环(全局拓扑),属于IGP。RFC 2328,“开放”意味着非私有的,对公众开放的。

  • OSPF的报文封装

  • OSPF协议包直接封装于IP,协议号89。

  • OSPF协议使用的组播地址

  • 所有OSPF路由器——224.0.0.5;DR BDR——224.0.0.6

  • OSPF路由协议的管理距离:110

二、路由重发步概念

  • 是可以将不同的自治系统他们之间的路由信息进行交换
  • 从一种协议到另外一种协议
  • 同一种协议的不同实例
  • 路由重发是针对外部的,自身的路由器不会有变化

拓扑

路由重发步
R2的环回接口接入ospf协议

R2#sh ip route
	1.0.0.0/24 is subnetted, 1 subnets
R	 1.1.1.0 [120/1] via 192.168.12.1, 00:00:15, Ethernet0/0
	2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C	 2.2.2.0/24 is directly connected, Loopback0
L	 2.2.2.2/32 is directly connected, Loopback0
	3.0.0.0/32 is subnetted, 1 subnets
O	 3.3.3.3 [110/11] via 192.168.23.3, 00:02:40, Ethernet0/1
	192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C	 192.168.12.0/24 is directly connected, Ethernet0/0
L	 192.168.12.2/32 is directly connected, Ethernet0/0
	192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C	 192.168.23.0/24 is directly connected, Ethernet0/1
L	 192.168.23.2/32 is directly connected, Ethernet0/1

R1#sh ip route
	1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C	 1.1.1.0/24 is directly connected, Loopback0
L	 1.1.1.1/32 is directly connected, Loopback0
	192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C	 192.168.12.0/24 is directly connected, Ethernet0/0
L	 192.168.12.1/32 is directly connected, Ethernet0/0

R3#sh ip route
	2.0.0.0/32 is subnetted, 1 subnets
O	 2.2.2.2 [110/11] via 192.168.23.2, 00:00:12, Ethernet0/0
	3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C	 3.3.3.0/24 is directly connected, Loopback0
L	 3.3.3.3/32 is directly connected, Loopback0
	192.168.23.0/24 i
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值