关于OSPF 实践

“环回口”(loopback address口)在BGP上也有用到,他是一种在路由器协议上广泛使用的虚拟接口。是通过系统的编撰,在物理基础上是实现的。
首先,如果在这台路由器上设置环回口,可以通过"telnet"命令登陆这台路由器。由于环回口是虚拟的,如果不特别的去设置关掉它,它就不会因为物各种故障失效(即down掉)。并且每个环回口都是独立的,也不会太占资源。
其次,环回口的ip地址可以作为OSPF协议下各个路由器的路由器号(即router id),环回口ip地址不但不会出现重复,并且它又稳定。所以它就成了作为router id的最佳选择。
还有,他可以作为一些其他服务对路由器的访问接口,如tftp、snmp、tacace/radius等等在BGP中它也很重要

loopback 环回接口地址作为路由协议的router-id,因为环回接口是逻辑接口,比物理接口更加稳定。在对网络操作时,网路管理员有可能误操作导致物理接口地址删除,或者改动,而环回接口则一般会回去改动

###查看环回接口地址

[R5]display interface LoopBack 0
LoopBack0 current state : UP
Line protocol current state : UP (spoofing)
Description:HUAWEI, AR Series, LoopBack0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 5.5.5.5/32
Physical is Loopback
Current system time: 2020-05-14 14:37:06-08:00
    Last 300 seconds input rate 0 bits/sec, 0 packets/sec
    Last 300 seconds output rate 0 bits/sec, 0 packets/sec
    Realtime 0 seconds input rate 0 bits/sec, 0 packets/sec
    Realtime 0 seconds output rate 0 bits/sec, 0 packets/sec
    Input: 0 bytes
    Output:0 bytes
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

###查看ip端口信息 

<R5>disp ip inter br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 5
The number of interface that is UP in Protocol is 4
The number of interface that is DOWN in Protocol is 5

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              unassigned           down       down      
GigabitEthernet0/0/1              172.16.12.1/24       up         up        
GigabitEthernet0/0/2              10.10.12.2/24        *down      down      
GigabitEthernet4/0/0              10.10.20.2/24        up         up        
GigabitEthernet4/0/1              unassigned           down       down      
GigabitEthernet4/0/2              unassigned           down       down      
GigabitEthernet4/0/3              unassigned           down       down      
LoopBack0                         5.5.5.5/32           up         up(s)

##修改 router id 为环回接口

[R5]router id 5.5.5.5

##查看 ospf router id 是物理接口,需要重启修改成 新的router id 

[R5]dis ospf peer br

     OSPF Process 1 with Router ID 172.16.12.1
          Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 ----------------------------------------------------------------------------
[R5]quit


 ###重启生效

<R5>reset ospf process 
Warning: The OSPF process will be reset. Continue? [Y/N]:y
<R5>sy
Enter system view, return user view with Ctrl+Z.


###确认是否修改

[R5]dis ospf peer br

     OSPF Process 1 with Router ID 5.5.5.5
          Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 ----------------------------------------------------------------------------
[R5]


ospf  

邻居表: 邻里关系
display osdf peer brief 

LSDB: 链路状态信息,并需要实时同步
display ospf lsdb 

路由表: spf ospf 中路由表单

display ospf route  


OSPF 原理:
1. ospf 要求运行osdf 的路由器都有整个网络的链路状态信息,这样才能计算出到达目的地的最优路径
2. 把LSA集来的信息 建立自己的数据库LSDB,并用SPF计算,建立起到达每个网络的最短路径树
3.通过最短路径树计算最优路由,并更新到自己的路由表汇总


Router ID 是一个32位的值,表示了一个自治系统内路由器,管理员可以为每台运行ospf 的路由器手动配置一个RouterID。可以自动生成,为了防止由于端口地址更改,ID 发生变化,建议手动设置

##修改之前确认是否有RouterID了,如果更改可以要重启下进程
[R1]ospf router-id 172.172.172.10
Info: The configuration succeeded. You need to restart the OSPF process to valid
ate the new router ID.


###这个是之前自动生成的RouterID
[R1]display ospf peer

     OSPF Process 1 with Router ID 172.16.10.1
     
#如果手动设置想要生效,需要重启 进程

<R1>reset ospf 1 process
Warning: The OSPF process will be reset. Continue? [Y/N]:y   
<R1>display ospf peer

     OSPF Process 1 with Router ID 172.172.172.10
## 确认应修改完成

router id 是整个自治域 唯一 

###开启debug 设置 如果关闭可以ctrl +o 

<R2>terminal debugging 
Info: Current terminal debugging is on.
<R2>termi    
<R2>terminal monit    
<R2>terminal monitor ?
  <cr>  Please press ENTER to execute command 
<R2>terminal monitor 
Info: Current terminal monitor is on.


<R2>debugging  ospf packet
<R2>
May 13 2020 17:10:18.346.1-08:00 R2 RM/6/RMDEBUG:

<R2>undo debugging all
Info: All possible debugging has been turned off
<R2>terminal debugging

配置ospf 是网络通信


###配置R1 路由器 

[R1]ospf 
[R1-ospf-1

[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]di th
[V200R003C00]
#
 area 0.0.0.0 
#
return
[R1-ospf-1-area-0.0.0.0]
[R1-ospf-1-area-0.0.0.0]
[R1-ospf-1-area-0.0.0.0]
[R1-ospf-1-area-0.0.0.0]network 172.16.10.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 10.10.20.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 10.10.10.0 0.0.0.255


###查看端口
<R1>disp ospf peer br

     OSPF Process 1 with Router ID 1.1.1.1
          Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/2             5.5.5.5          Full        
 ----------------------------------------------------------------------------
##查看路由  
<R1>disp ospf routing 

     OSPF Process 1 with Router ID 1.1.1.1
          Routing Tables 

 Routing for Network 
 Destination        Cost  Type       NextHop         AdvRouter       Area
 10.10.20.0/24      1     Transit    10.10.20.1      1.1.1.1         0.0.0.0
 172.16.10.0/24     1     Stub       172.16.10.1     1.1.1.1         0.0.0.0
 172.16.12.0/24     2     Stub       10.10.20.2      5.5.5.5         0.0.0.0

 Total Nets: 3  
 Intra Area: 3  Inter Area: 0  ASE: 0  NSSA: 0 
###查看库文件
<R1>disp ospf lsdb

     OSPF Process 1 with Router ID 1.1.1.1
         Link State Database 

                 Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    1.1.1.1         1.1.1.1            351  48    80000006       1
 Router    5.5.5.5         5.5.5.5            369  48    80000007       1
 Network   10.10.20.2      5.5.5.5            369  32    80000002       0

####配置 R5 路由器 

[R5]ospf
[R5-ospf-1]di th
[V200R003C00]
#
ospf 1 
#
return
[R5-ospf-1]are    
[R5-ospf-1]area 0
[R5-ospf-1-area-0.0.0.0]dis ip inter br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 5
The number of interface that is UP in Protocol is 4
The number of interface that is DOWN in Protocol is 5

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              unassigned           down       down      
GigabitEthernet0/0/1              172.16.12.1/24       up         up        
GigabitEthernet0/0/2              10.10.12.2/24        *down      down      
GigabitEthernet4/0/0              10.10.20.2/24        up         up        
GigabitEthernet4/0/1              unassigned           down       down      
GigabitEthernet4/0/2              unassigned           down       down      
GigabitEthernet4/0/3              unassigned           down       down      
LoopBack0                         5.5.5.5/32           up         up(s)     
NULL0                             unassigned           up         up(s)     
[R5-ospf-1-area-0.0.0.0]network 10.10.12.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 10.10.20.0 0.0.0.255
[R5-ospf-1-area-0.0.0.0]network 172.16.12.0 0.0.0.255

##查看ospf 的路由 
[R5-ospf-1-area-0.0.0.0]disp ospf routing 

     OSPF Process 1 with Router ID 5.5.5.5
          Routing Tables 

 Routing for Network 
 Destination        Cost  Type       NextHop         AdvRouter       Area
 10.10.20.0/24      1     Transit    10.10.20.2      5.5.5.5         0.0.0.0
 172.16.12.0/24     1     Stub       172.16.12.1     5.5.5.5         0.0.0.0
 172.16.10.0/24     2     Stub       10.10.20.1      1.1.1.1         0.0.0.0

 Total Nets: 3  
 Intra Area: 3  Inter Area: 0  ASE: 0  NSSA: 0 

[R5-ospf-1-area-0.0.0.0]

###LSDB: 链路状态信息,并需要实时同步
[R5-ospf-1-area-0.0.0.0]disp ospf lsdb

     OSPF Process 1 with Router ID 5.5.5.5
         Link State Database 

                 Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    1.1.1.1         1.1.1.1            149  48    80000006       1
 Router    5.5.5.5         5.5.5.5            165  48    80000007       1
 Network   10.10.20.2      5.5.5.5            165  32    80000002       0

###修改DR 权限 更新DB 

#####查看DR 和BDR 

Enter system view, return user view with Ctrl+Z.
[R5]disp ospf peer 

     OSPF Process 1 with Router ID 5.5.5.5
         Neighbors 

 Area 0.0.0.0 interface 10.10.20.2(GigabitEthernet4/0/0)s neighbors
 Router ID: 1.1.1.1          Address: 10.10.20.1      
   State: Full  Mode:Nbr is  Slave  Priority: 1
   DR: 10.10.20.2  BDR: 10.10.20.1  MTU: 0    
   Dead timer due in 30  sec 
   Retrans timer interval: 5 
   Neighbor is up for 00:27:01     
   Authentication Sequence: [ 0 ]

##确认 DB 是R5  DBR 是R1 

##升级R1 为DB,R5 为DBR 

##在 R1 上提升权限为2 
[R1-GigabitEthernet0/0/2]ospf dr-priority 2
[R1-GigabitEthernet0/0/2]disp ospf peer

     OSPF Process 1 with Router ID 1.1.1.1
         Neighbors 

 Area 0.0.0.0 interface 10.10.20.1(GigabitEthernet0/0/2)s neighbors
 Router ID: 5.5.5.5          Address: 10.10.20.2      
   State: Full  Mode:Nbr is  Master  Priority: 1
   DR: 10.10.20.2  BDR: 10.10.20.1  MTU: 0    
   Dead timer due in 35  sec 
   Retrans timer interval: 5 
   Neighbor is up for 00:31:01     
   Authentication Sequence: [ 0 ] 
   
   发现 没有改变,因为DR 是非抢占的,需要重启R5 的 ospf 协议 
   
 <R5>reset ospf process  
   
  <R5>disp ospf peer

     OSPF Process 1 with Router ID 5.5.5.5
         Neighbors 

 Area 0.0.0.0 interface 10.10.20.2(GigabitEthernet4/0/0)s neighbors
 Router ID: 1.1.1.1          Address: 10.10.20.1      
   State: Full  Mode:Nbr is  Slave  Priority: 2
   DR: 10.10.20.1  BDR: 10.10.20.2  MTU: 0    
   Dead timer due in 32  sec 
   Retrans timer interval: 0 
   Neighbor is up for 00:00:18     
   Authentication Sequence: [ 0 ] 

<R5>

 

 

###ospf 可以在接口下设置 认证和开销
 

在R5 上进行设置,
[R5-GigabitEthernet4/0/0]ospf authentication-mode ?
  hmac-md5  Use HMAC-MD5 algorithm
  keychain  Keychain authentication mode
  md5       Use MD5 algorithm
  null      Use null authentication
  simple    Simple authentication mode
[R5-GigabitEthernet4/0/0]ospf authentication-mode md    
[R5-GigabitEthernet4/0/0]ospf authentication-mode md5 ?
  INTEGER<1-255>  Key ID
  <cr>            Please press ENTER to execute command 
[R5-GigabitEthernet4/0/0]ospf authentication-mode md5 1 ?
  STRING<1-255>/<20-392>  The password (key)
  cipher                  Encryption type (Cryptogram)
  plain                   Encryption type (Plain text)
[R5-GigabitEthernet4/0/0]ospf authentication-mode md5 1 ci    
[R5-GigabitEthernet4/0/0]ospf authentication-mode md5 1 cipher ?
  STRING<1-255>/<20-392>  The password (key)
[R5-GigabitEthernet4/0/0]ospf authentication-mode md5 1 huayun
[R5-GigabitEthernet4/0/0]quit
[R5]q
<R5>save
  The current configuration will be written to the device. 
  Are you sure to continue? (y/n)[n]:y
  It will take several minutes to save configuration file, please wait.......
  Configuration file had been saved successfully
  Note: The configuration file will take effect after being activated
<R5>
May 14 2020 15:32:43-08:00 R5 %%01OSPF/3/NBR_CHG_DOWN(l)[0]:Neighbor event:neigh
bor state changed to Down. (ProcessId=256, NeighborAddress=1.1.1.1, NeighborEven
t=InactivityTimer, NeighborPreviousState=Full, NeighborCurrentState=Down) 
<R5>
May 14 2020 15:32:43-08:00 R5 %%01OSPF/3/NBR_DOWN_REASON(l)[1]:Neighbor state le
aves full or changed to Down. (ProcessId=256, NeighborRouterId=1.1.1.1, Neighbor
AreaId=0, NeighborInterface=GigabitEthernet4/0/0,NeighborDownImmediate reason=Ne
ighbor Down Due to Inactivity, NeighborDownPrimeReason=Hello Not Seen, NeighborC
hangeTime=2020-05-14 15:32:43-08:00) 
<R5>
###发现ping 的动作无法通过 
From 172.16.12.12: bytes=32 seq=324 ttl=126 time=15 ms
From 172.16.12.12: bytes=32 seq=325 ttl=126 time=16 ms
From 172.16.12.12: bytes=32 seq=326 ttl=126 time=31 ms
Request timeout!
Request timeout!
Request timeout!
Request timeout!

--- 172.16.12.12 ping statistics ---

###在R1 上进行 做同样配置

R1-GigabitEthernet0/0/2]ospf auth    
[R1-GigabitEthernet0/0/2]ospf authentication-mode md    
[R1-GigabitEthernet0/0/2]ospf authentication-mode md5 1    
[R1-GigabitEthernet0/0/2]ospf authentication-mode md5 1     
[R1-GigabitEthernet0/0/2]ospf authentication-mode md5 1?
  INTEGER<1-255>  Key ID
[R1-GigabitEthernet0/0/2]ospf authentication-mode md5 1 huayun
[R1-GigabitEthernet0/0/2]
May 14 2020 15:34:47-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[0]:Neighbor changes eve
nt: neighbor status changed. (ProcessId=256, NeighborAddress=2.20.10.10, Neighbo
rEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) 
[R1-GigabitEthernet0/0/2]
May 14 2020 15:34:47-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[1]:Neighbor changes eve
nt: neighbor status changed. (ProcessId=256, NeighborAddress=2.20.10.10, Neighbo
rEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=ExStart) 
[R1-GigabitEthernet0/0/2]
May 14 2020 15:34:47-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes eve
nt: neighbor status changed. (ProcessId=256, NeighborAddress=2.20.10.10, Neighbo
rEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exch
ange) 
[R1-GigabitEthernet0/0/2]
May 14 2020 15:34:47-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes eve
nt: neighbor status changed. (ProcessId=256, NeighborAddress=2.20.10.10, Neighbo
rEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loadin
g) 
[R1-GigabitEthernet0/0/2]
May 14 2020 15:34:47-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes eve
nt: neighbor status changed. (ProcessId=256, NeighborAddress=2.20.10.10, Neighbo
rEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) 
[R1-GigabitEthernet0/0/2]

###发现 ospf 开始 Init -》ExStart -》 Exchange -》Loading -》 Full


##ping 状态重新通信

From 172.16.12.12: bytes=32 seq=12 ttl=126 time=32 ms
From 172.16.12.12: bytes=32 seq=13 ttl=126 time=15 ms
From 172.16.12.12: bytes=32 seq=14 ttl=126 time=32 ms

--- 172.16.12.12 ping statistics ---
  14 packet(s) transmitted
  13 packet(s) received
  7.14% packet loss
  round-trip min/avg/max = 0/28/32 ms

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

石兴稳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值