diff --git a/Info/Layer3.pm b/Info/Layer3.pm index 894a2e8a..5b895f68 100644 --- a/Info/Layer3.pm +++ b/Info/Layer3.pm @@ -157,6 +157,14 @@ sub root_ip { my $router_ip = $l3->router_ip(); my $ospf_ip = $l3->ospf_ip(); + # if the router ip exists and is a route advertised by the device we prefer + # it over the others + return $router_ip + if (( defined $router_ip ) + and ( $router_ip ne '0.0.0.0' ) + and ( grep { $_ eq $router_ip } (keys %ospf_ip)) ) + and ( $l3->snmp_connect_ip($router_ip) ) ); + # return the first one found here (should be only one) if ( defined $ospf_ip and scalar( keys %$ospf_ip ) ) { foreach my $key ( keys %$ospf_ip ) {