show interfaces lo【IP Address 】字段映射到 数据库 routeinfo【唯一标识 id】。
数据存储:处理后的数据上传到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/32
PE1# 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/32
PE2# 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/32
CE1# show int br
Interface Status VRF Addresses
--------- ------ --- ---------
eth0 up default 172.16.1.2/24
lo up default 192.168.1.1/24
CE2# show int br
Interface Status VRF Addresses
--------- ------ --- ---------
eth0 up default 172.16.2.2/24
lo up default 192.168.2.1/24
CE3# show int br
Interface Status VRF Addresses
--------- ------ --- ---------
eth0 up default 172.16.3.2/24
lo up default 192.168.3.1/24
CE4# 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 2000 eth0
2.2.2.2 10.1.2.2 255.255.255.255 UGH 2000 eth1
10.1.1.0 0.0.0.0 255.255.255.0 U 000 eth0
10.1.2.0 0.0.0.0 255.255.255.0 U 000 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 2000 eth0
9.9.9.9 10.1.1.254 255.255.255.255 UGH 2000 eth0
10.1.1.0 0.0.0.0 255.255.255.0 U 000 eth0
10.1.2.0 10.1.1.254 255.255.255.0 UG 2000 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 2000 eth0
9.9.9.9 10.1.2.254 255.255.255.255 UGH 2000 eth0
10.1.1.0 10.1.2.254 255.255.255.0 UG 2000 eth0
10.1.2.0 0.0.0.0 255.255.255.0 U 000 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 2000 eth0
172.16.1.0 0.0.0.0 255.255.255.0 U 000 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 2000 eth0
172.16.2.0 0.0.0.0 255.255.255.0 U 000 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 2000 eth0
172.16.3.0 0.0.0.0 255.255.255.0 U 000 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 2000 eth0
172.16.4.0 0.0.0.0 255.255.255.0 U 000 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