一.实验显示邻居和邻接过程的建立
Loopback0 1.1.1.11 R11 s0/0 12.1.1.11
S0/0 12.1.1.2 Loopback2.2.2.2 0 R22 子网掩码:255.255.255.252
此实验(lab2)只是启用r1 ,r2 来验证邻接和邻居关系的建立,首先给r1和r2配置 r1>en r1#conf t
r1(config)#interface loopback 0//创建环回口 r1(config-if)#ip address 1.1.1.1 255.255.255.0 r1(config-if)#exit r1(config)#int s0/0
r1(config-if)#ip add 12.1.1.1 255.255.255.252//给路由器R1 的S0接口配IP地址 r1(config-if)#exit
r1(config)#router ospf 100
r1(config-router)#router-id 1.1.1.1(1.1.1.1随便写)
r1(config-router)#network 1.1.1.0 0.0.0.255 area 0 // 宣告loopback地址
r1(config-router)#net 12.1.1.0 0.0.0.3 area 0//宣告互联地址 0.0.0.3 反掩码 r1(config-router)#int s 0/0
r1(config-if)#shut 出现: Interface Serial0/0, changed state to administratively down Line protocol on Interface Serial0/0, changed state to down
把s0/0接口先DOWN了,关闭的目的是让R1和R2之间不能够进行通信,他们之间不能学习。因为我们是要观察OSPF建立邻接关系的过程,然后再把他们启用起来,让大家看启用过程
下面是对R2路由器的配置 r2>en r2#conf t
r2(config)#interface loopback 0//创建环回口 r2(config-if)#ip address 2.2.2.2 255.255.255.0 r2(config-if)#exit r2(config)#int s0/0 r2(config)#no shut
r2(config-if)#ip add 12.1.1.2 255.255.255.252//给路由器R1 的S0接口配IP地址
r2(config-if)#exit
r2(config)#router ospf 100
r2(config-router)#router-id 2.2.2.2
r2(config-router)#network 2.2.2.0 0.0.0.255 area 0 r2(config-router)#network 12.1.1.0 0.0.0.3 area 0 r2(config-router)#end
r2#debug ip ospf events //打开调试信息页面 出现:OSPF enents debugging is on ,它能反映OSPF建立邻接关系的各个阶段,他们的协商过程。但是对于包类型反映的不是很精准。loading状态通过event过程看的不是很清楚。所以把这条命令和下条命令结合起来看 r2#debug ip ospf pack//单独打开此命令,只能看到何时收到了什么包,不显示发送
在R1中同样使用这两条debug命令,在此用do是因为模式不一样,目前是接口配置模式可以加上do
r1(config-if)#do debug ip ospf events r1(config-if)#do debug ip ospf pack
接下来看结果在R1中
r1(config-if)#no shut// 输入该命令后就建立了,等待看结果 r1(config-if)#end 当出现
serial0/0 from loading to full,loading done //这个FULL状态,就算调试结束,然后关闭调试信息
r1#no debug ip ospf even r1#no debug ip ospf pack r2#no debug ip ospf even
r2#no debug ip ospf pack 接下来看中间的调试信息
调试:
r1#show ip route
R1显示路由信息出现:
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 12.1.1.2, 00:07:00, Serial0/0 12.0.0.0/30 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial0/0 R2显示路由信息出现:
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.1.1.1, 00:11:00, Serial0/0 2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0 12.0.0.0/30 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial0/0 r1#show ip ospf interface
r1#show ip ospf neighbor
显示:Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:39 12.1.1.2 Serial0/0
二.对单区域的OSPF配置加以扩展(lab3) 1.路由器router id的配置
CCNA阶段:单区域的router id的配置,启动OSPF以后看一下有没有loopback地址,如果有,就比较loopback地址,如果没有就找接口地址,总之就是参与OSPF进程里面的活动的接口地址,哪个高,做为该路由器的router id
在NP中学会去指定一个router id,虽然学会了,但是大家不能去这样做,仍然建议大家使用loopback地址去确定路由器的router id 查看OSPF的router id: 输入:r1#show ip ospf
提示:routing process\"osfp 100\" with ID 1.1.1.1 //进程号是100路由器的router id 是1.1.1.1,配置过程:先进入到OSPF里面去 r1#conf t
r1(config)#router ospf 100//进入100进程
r1(config-router)#router-id 1.1.1.4 //修改router-id为一个IP地址
显示:Reload or use \"clear ip ospf process\" command, for this to take effect r1(config-router)#end
查看:r1#show ip ospf //发现还是没有变routing process\"osfp 100\" with ID 1.1.1.1,因为重启路由器才能发生作用:reload or use \"clear ip ospf process\"command,for this to take effect 所以我们就键入该命令
输入:r1#clea ip ospf process
提示:reset all ospf processes?[no]:y
r1#show ip ospf //发现变化了:routing process\"osfp 100\" with ID 1.1.1.4 下面我们把它NO掉 我们先看一下 r1#show run 显示:router-id 1.1.1.4 下面把他NO掉: r1#conf t
r1(config)#router ospf 100
r1(config-router)#no router-id 1.1.1.4 r1(config-router)#end r1#clea ip ospf process
提示:reset all ospf processes?[no]:y r1#end
再来看r1#show ip ospf 发现变回去了
2.环回接口:最大特点永远不会DOWN,从物理意义上讲,还回口不存在,所以不会出现故障,虚拟出来的虚链路。再稳定的电路也不能保证不出故障。下面是查看环回口的命令 先打开接口(lab3) r1#conf t
r1(config)#int lo0
r1(config-if)#no shut r1(config-if)#end
查看环回口命令:r1#show int lo 0
显示:loopback0 is up, line protocol is up Hardware is loopback
3.下面讲修改度量值,如何修改度量值(默认成本)?100M除以该接口的实际带宽, 所以对于百兆的度量值是1,对于10M的链路就是10 r1#conf t
r1(config)#int s 0/0
r1(config-if)#ip ospf cost ? 提示:<1-65535> cost 配置cost=1,链路是100M 会不会有65535出现? 如果配置cost=65535,100M/65535=0.001525M,说明你的链路是0.001525M也就是大概1K,有没有1K的链路呢(此时单位还是位)?没有!!所以不会有65535。
另外说明,运营商在偷换一个概念,虽然ADSL号称1M,但是单位是位bit,要除以8才得到字节,了不起就是100多K,达到100多K实际以及很好了 。
所以:cost的值越大,说明实际带宽越低,当cost=65535,说明实际带宽只有1K 修改:r1(config-if)#ip ospf cost :此命令使用起来不方便,后期维护也比较麻烦 所以使用:打入:r1(config-if)#bandwidth ?
显示:<1-10000000> bandwidth in kilobits //表示单位是K
打入命令:r1(config-if)#bandwidth 这样运用到工程里面就知道了接口实际带宽是多大,而且OSPF在参与度量值进行运算的时候会使用bandwidth所指定的带宽 情况一:如果我不配OSPF 的cost 也不配bandwidth。OSPF的度量值就是默认用100M/接口带宽,如果串行接口,默认14。配了bandwidth,就用100M/bandwidth
如果不指定 r1(config-if)#do show int s0/0 //第四行就显示BW 14 Kbit/S,因为在同步串行链路上,无论物理链路的时钟速率是多少,默认带宽就是14 Kbit/S 情况二:如果我们指定带宽,再来看一下: r1(config-if)#int s 0/0
r1(config-if)#bandwidth //通过no bandwidth 去除设置的带宽,带宽变为14 r1(config-if)#do show int s0/0 //第四行显示BW Kbit,此时,cost也随之变化了,所以没有必要费事的去计算cost(100M/实际带宽),然后再根据计算出来的结果 输入:r1(config-if)#ip ospf cost *(其中* 表示:计算出来的结果)。只需要直接去定义bandwidth即可。
(另外:如果指定了bandwidth ,又想恢复为默认值,以下操作完成: r1(config-if)#int s 0/0
r1(config-if)#no bandwidth //通过no bandwidth 去除设置的带宽,带宽变为14 r1(config-if)#do show int s0/0 第四行显示:BW 14 Kbit )
1.r1(config)#int s0/0
r1(config-if)# bandwidth 10000 //10M带宽,cost=10 r1(config-if)#end
r1#show ip ospf int //显示cost=10,100M/带宽得到cost
2.r1(config)#int s0/0
r1(config-if)# bandwidth 100000 //100M带宽,cost=1 r1(config-if)#end
r1#show ip ospf int //显示cost=1,100M/带宽得到cost
如果你是千兆的网络,cost=0.1 而cost范围是1-65535 ,此时可以改默认的100M,改分子 如果不改分子的话,千兆链路和百兆链路计算出来的OSPF值都是1,如果多条链路,有千兆,有百兆,就会引起负载均衡,那千兆的链路就没有意义了。 我们举例来看一下千兆网络的cost值: r1#conf t
r1(config)#int s 0/0
r1(config-if)#band 1000000//把带宽改为1000M。band的单位是K r1(config-if)#end
r1#show run int s 0/0 //看到bandwidth变为1000兆
r1#show ip ospf int //看到cost:1,开销依然是1 Network Type POINT_TO_POINT, Cost: 1 OSPF默认的情况下把百兆和千兆链路cost值都认为是1,它无法去分辨哪个1,哪个是10,它即使能分辨出,但计算的cost都是1,是这种情况不是我们希望的。 对于这种情况我们怎么办呢? 方法一:这种方式NA已经讲过
手工去指定某个接口的OSPF值,千兆指定为1,百兆指定为10。 r1#conf t
r1(config)#int s 0/0
r1(config-if)#ip ospf cost 10//强行指定为10 r1(config-if)#end
r1#show ip ospf int//发现cost为10
方法二:修改分子,分子默认是100兆去除,现在把它改成1000兆,对于千兆链路,cost=1.百兆链路cost=10 ,这样OSPF开销值不一样,通信的时候就好处理了。
强调一点:有一台改分子了,所有参加计算的OSPF域里面的路由器分子都要修改。这样网络才比较稳定
如果不同时改,R1或者R2上改“分子”为1000兆,改过分子的路由器会计算出千兆链路的OSPF的cost=1,百兆OSPF的cost=10,会选择千兆链路来传输数据,“没改分子值的路由器”会认为千兆和百兆的cost都为1,它给改了“分子值的路由器”回送确认包的时候,数据的时候会从两条链路传输。一边使用一条线路,一边使用两条线路,就会产生丢包现象,线路不稳定。还有速度会降下来,本来可以用千兆链路传输,现在两台链路都是100兆。 所管辖区域内的路由器要改所有都改,如何进行修改?如下: r1#conf t
r1(config)#router ospf 100
r1(config-router)#auto-cost reference-bandwidth 1000//注意这里是1000M 出现:%ospf:reference bandw...is changed.
please ensure reference bandwidth is consistent across all routers.//这个是告警提示,没有任何关系告诉路由器,以后算开销的时候分子是1000M *预先定义S0/0口是1000000(1000M)链路 r1(config)#int s0/0
r1(config-if)#bandwidth 1000000//六个零
r1(config-if)#end r1#show run int s0/0
如果显示:interface s0/0
bandwidth 1000000//这个表明是1000M链路,六个零 ip add ...
ip ospf cost 10//刚刚人为的强制将OSPF的cost值设置为10 ....
去除ip ospf cost 10 命令是:r1#conf t
r1(config)#int s 0/0
r1(config-if)#no ip ospf cost 10 r1(config-if)#end
r1#show ip ospf int //结果看到cost:1,因为S0/0口本来就是千兆链路,而定义的auto-cost reference bandwidth 1000,所以相除结果就是1。 现在我们改为100M链路,预期结果应该cost是10 看一下:r1#conf t
r1(config)#int s 0/0
r1(config-if)#band 100000//5个零 100M链路 r1(config-if)#end
r1#show ip ospf int//该命令可能要打两次 显示:cost:10
分子最大能有多大? r1#conf t
r1(config)#router ospf 100
r1(config-router)#auto-cost reference-bandwidth ? 显示:<1-4294967>
4.改变OSPF中路由器的优先级:思科路由器默认的优先级是1,为何要改变路由器的优先级,就是为了选举DR/BDR.在优先级一样的情况下要看router-id.当优先级不一样的时候,优先级直接决定了DR和BDR,优先级越大,就是DR,次之,就是BDR,当某台路由器OSPF优先级为0的时候,永远都不能成为DR和BDR,换句话说,当某台路由器优先级为0的时候,该路由器将不参与选举。点对点的OSPF中没有DR和BDR?而router-id都没有配的情况下由loopback来决定,loopback如果大家都没有配,就比较参与ospf进程里面的接口IP地址
修改OSPF优先级:
进入参与OSPF进程的接口 r1#conf t
r1(config)#router ospf 100 r1(config-router)#int s0/0 r1(config-if)#ip ospf priority ? 范围:<0-255>
如果优先级选为0,他永远不可能成为DR,BDR,因为他不参与选举,也不会被选举,谁优先级最高谁就是DR,次之就是BDR,那<0-255>
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- huatuo0.com 版权所有 湘ICP备2023021991号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务