Kaspars Zibarts

Oneliner to compare routes between two cluster members

Discussion created by Kaspars Zibarts on Mar 1, 2018
Latest reply on Mar 1, 2018 by Kaspars Zibarts

Running into "get interfaces with topology" feature problem recently due to route mismatch on cluster members prompted me to write a quick one-liner to compare routes with least possible effort.

It must be noted for example simplicity I used SNMP V1 with public community (which is not advisable in production) so update command snmp part in red accordingly. Also it does require that SNMP port is open on Sync interface (IPs from cphaprob stat output)

 

For example below I added a dummy 1.1.1.1/32 route to FW1

[Expert@fw1:0]# i=0; cphaprob stat | egrep ^[1,2] | sed 's/(local)//' | awk '{print $2}'| while read line; do let i++; snmpwalk -c public -v 1 $line IP-FORWARD-MIB::inetCidrRouteIfIndex.ipv4 | awk -F\" '{print $2, $4, substr($3,2,2)}' > fw.$i; done; if [ `diff -q fw.1 fw.2 | wc -l` -gt 0 ]; then diff fw.1 fw.2; else echo "Routes OK"; fi
2d1
< 1.1.1.1 10.3.81.67 32

 

NormaL output would be

[Expert@fwfran1:0]# i=0; cphaprob stat | egrep ^[1,2] | sed 's/(local)//' | awk '{print $2}'| while read line; do let i++; snmpwalk -c public -v 1 $line IP-FORWARD-MIB::inetCidrRouteIfIndex.ipv4 | awk -F\" '{print $2, $4, substr($3,2,2)}' > fw.$i; done; if [ `diff -q fw.1 fw.2 | wc -l` -gt 0 ]; then diff fw.1 fw.2; else echo "Routes OK"; fi
Routes OK

Outcomes