一.BFD监测网络状态
BFD(BidrectionaL Forwarding Detection 双向转发检测)用于快速检测系统设备之间的发送和接受两个方向的通信故障,并在出现故障时通知生成应用。BFD 广泛用于链路故障检测,并能实现与接口、静态路由、动态路由等联动检测。bfd 使用的默认组播地址(默认就是 224.0.0.184)。
[R1] ip route-static 2.2.2.0 24 12.1.1.2
R1的配置
int g0/0/0
ip address 12.1.1.1 24
ip route static 2.2.2.0 255.255.255.0 12.1.1.2 #配置到达R2的路由
R2的配置
int g0/0/0
ip address 12.1.1.2 24
int lo0 #环回地址
ip address 2.2.2.2 24
如果将 R2 的int g0/0/0 shut down,R1已经ping不通R2,但是R1到R2的静态路由依然在
如果想实现R2不可达时,display ip routing-table中的静态路由消失
R1的配置
bfd R1R2 bind peer-ip 12.1.1.2 source-ip 12.1.1.1 autoR2的配置
bfd r1r2 bind peer-ip 12.1.1.1 source-ip 12.1.1.2 auto
注:如果有一端不支持bfd,可以配置单臂回声
bfd r1r2 bind peer-ip 12.1.1.1 source-ip 12.1.1.2 one-arm-echo
可以通过以下命令查看bfd状态:
display bfd session all
接着在R1-R2之间部署BFD来检测对端状态
[Rl] ip route-static 2.2.2.0 24 12.1.1.2 track bfd-session r1r2
现在shut down R2的g0/0/0端口,查看bfd状态为down
display bfd session all
同时查看路由表:静态路由表消失
display ip routing-table
若 undo shutdown,bfd会up,静态路由表会出现
二. NQA检测网络状态
NQA(Network Quality Analysis,网络质量分析)是系统提供的一个特性,位于链路层之上,覆盖网络层、传输层、应用层,独立于底层硬件,可实现实时监视网络性能状况,在网络发生故事进行故障诊断和定位。
NQA 通过发送测试报文,对网络性能或服务质量进行分析,NQA 支持的测试包括多种协议,例如 http 的延迟、TCP 延迟、DNS 错误、ICMP 消息等。
案例:
AR1的配置
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip address 12.1.1.1 24 [Huawei-GigabitEthernet0/0/0]qu [Huawei]nqa test-instance root icmp //创建一个nqa测试实例,测试管理账户名为root,测试实例名称为icmp [Huawei-nqa-root-icmp]test-type icmp //测试类型为icmp协议测试 [Huawei-nqa-root-icmp]frequency 10 //指定连续两次探测时间间隔为10s [Huawei-nqa-root-icmp]probe-count 2 //指定一次探测进行的测试次数 [Huawei-nqa-root-icmp]destination-address ipv4 12.1.1.2 //测试的对端ip地址 [Huawei-nqa-root-icmp]start now //启动当前测试 [Huawei-nqa-root-icmp]qu [Huawei]
AR2的配置
<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip address 12.1.1.2 24 Oct 28 2023 16:29:10-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [Huawei-GigabitEthernet0/0/0]qu [Huawei]
在AR1上使用检测命令:display nqa results,可以看到测试结果,查看网络性能。
display nqa results test-instance root icmp
NQA entry(root, icmp) :testflag is active ,testtype is icmp 1 . Test 81 result The test is finished Send operation times: 2 Receive response times: 2 Completion:success RTD OverThresholds number: 0 Attempts number:1 Drop operation number:0 Disconnect operation number:0 Operation timeout number:0 System busy operation number:0 Connection fail number:0 Operation sequence errors number:0 RTT Status errors number:0 Destination ip address:12.1.1.2 Min/Max/Average Completion Time: 20/20/20 Sum/Square-Sum Completion Time: 40/800 Last Good Probe Time: 2023-10-28 16:42:07.5 Lost packet ratio: 0 % 2 . Test 82 result The test is finished Send operation times: 2 Receive response times: 2 Completion:success RTD OverThresholds number: 0 Attempts number:1 Drop operation number:0 Disconnect operation number:0 Operation timeout number:0 System busy operation number:0 Connection fail number:0 Operation sequence errors number:0 RTT Status errors number:0 Destination ip address:12.1.1.2 Min/Max/Average Completion Time: 10/20/15 Sum/Square-Sum Completion Time: 30/500
静态路由或默认路由后面可以track BFD,也可以track NQA
命令与BFD相似:
ip route-static 0.0.0.0 0 12.1.1.2 track nqa root icmp //在主默认路由上挂接nqa