> 文章列表 > FRRoute 路由信息采集 + MPLS VPN隧道信息采集与识别

FRRoute 路由信息采集 + MPLS VPN隧道信息采集与识别

FRRoute 路由信息采集 + MPLS VPN隧道信息采集与识别

FRRoute 路由信息采集 + MPLS VPN隧道信息采集与识别

  • FRRoute
    • 数据库-表
    • 路由信息采集
      • 命令输出字段 -> 映射到 -> 数据库字段
      • 数据结构 + 算法
      • show int br
      • route -n
      • show interfaces lo
    • MPLS VPN隧道信息采集与识别
      • step 1 : 采集mpls邻居表
      • step 2 : MPLS 隧道识别

FRRoute

数据库-表

routeinfo
id				next_hop	eth_ip		metric
10.1.1.1	10.1.1.10	10.1.1.9	
10.1.1.1	10.1.1.2	10.1.1.1	
10.1.1.1	192.1.1.0	24	
10.1.1.2	10.1.1.1	10.1.1.2	
10.1.1.2	10.1.1.14	10.1.1.13	
10.1.1.2	192.1.6.0	24	
10.1.1.5	10.1.1.6	10.1.1.5	
10.1.1.5	10.1.1.9	10.1.1.10	
10.1.1.5	192.1.5.0	24	
10.1.1.6	10.1.1.13	10.1.1.14	
10.1.1.6	10.1.1.5	10.1.1.6	
10.1.1.6	192.1.7.0	24	mplsneighbor
RouterIp	next_hop	isPE

FRRoute 路由信息采集 + MPLS VPN隧道信息采集与识别

FRRoute 路由信息采集 + MPLS VPN隧道信息采集与识别

路由信息采集

命令输出字段 -> 映射到 -> 数据库字段

  1. FRR采集命令:
    • show int br 命令采集
      • 一个路由的每个【接口 Interface】 对应的
      • 【ip 地址 Addresses】,作为【接口ip eth_ip】。
    • route-n 采集
      • 各接口对应的 【Gateway】,作为【下一跳 ip 地址 next_hop】。
    • show interfaces lo 采集
      • 路由器的 第一个【lo】的
      • 【环回接口 IP Address】,作为该路由器的【唯一标识 id】。
  2. 采集字段处理:
    • show int br 【Addresses】字段映射到 数据库 routeinfo【接口ip eth_ip】,
    • route-n 【Gateway】字段映射到 数据库 routeinfo 的【下一条ip地址 next_hop】,
    • show interfaces lo【IP Address 】字段映射到 数据库 routeinfo【唯一标识 id】。
  3. 数据存储:处理后的数据上传到mysql数据库。

数据结构 + 算法

map<>

show int br

PR# show int br
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
eth0            up      default         10.1.1.254/24
eth1            up      default         10.1.2.254/24
lo              up      default         9.9.9.9/32PE1# show int br
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
CUSTA           up      CUSTA           
eth1            up      CUSTA           172.16.1.254/24
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
CUSTB           up      CUSTB           
eth2            up      CUSTB           172.16.3.254/24
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
eth0            up      default         10.1.1.2/24
lo              up      default         1.1.1.1/32PE2# show int br
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
CUSTA           up      CUSTA           
eth1            up      CUSTA           172.16.2.254/24
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
CUSTB           up      CUSTB           
eth2            up      CUSTB           172.16.4.254/24
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
eth0            up      default         10.1.2.2/24
lo              up      default         2.2.2.2/32CE1# show int br
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
eth0            up      default         172.16.1.2/24
lo              up      default         192.168.1.1/24CE2# show int br
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
eth0            up      default         172.16.2.2/24
lo              up      default         192.168.2.1/24CE3# show int br
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
eth0            up      default         172.16.3.2/24
lo              up      default         192.168.3.1/24CE4# show int br
Interface       Status  VRF             Addresses
---------       ------  ---             ---------
eth0            up      default         172.16.4.2/24
lo              up      default         192.168.4.1/24
CE4# 

route -n

PR:
bash-5.0# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
1.1.1.1         10.1.1.2        255.255.255.255 UGH   20     0        0 eth0
2.2.2.2         10.1.2.2        255.255.255.255 UGH   20     0        0 eth1
10.1.1.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.1.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth1
PE1:
bash-5.0# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
2.2.2.2         10.1.1.254      255.255.255.255 UGH   20     0        0 eth0
9.9.9.9         10.1.1.254      255.255.255.255 UGH   20     0        0 eth0
10.1.1.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.1.2.0        10.1.1.254      255.255.255.0   UG    20     0        0 eth0
PE2:
bash-5.0# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
1.1.1.1         10.1.2.254      255.255.255.255 UGH   20     0        0 eth0
9.9.9.9         10.1.2.254      255.255.255.255 UGH   20     0        0 eth0
10.1.1.0        10.1.2.254      255.255.255.0   UG    20     0        0 eth0
10.1.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
CE1# exit
bash-5.0# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.16.1.254    0.0.0.0         UG    20     0        0 eth0
172.16.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
CE2# exit
bash-5.0# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.16.2.254    0.0.0.0         UG    20     0        0 eth0
172.16.2.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
CE3# exit
bash-5.0# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.16.3.254    0.0.0.0         UG    20     0        0 eth0
172.16.3.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
CE4# exit
bash-5.0# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.16.4.254    0.0.0.0         UG    20     0        0 eth0
172.16.4.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0

show interfaces lo

frr_router# show interfaces lo
Interface  IP Address                   Status          Protocol    MTU
lo         192.168.1.1/32               up              up          65536
lo:1       10.0.0.1/32                  up              up          65536
lo:2       172.16.1.1/32                up              up          65536

MPLS VPN隧道信息采集与识别

step 1 : 采集mpls邻居表

step 2 : MPLS 隧道识别