Add DHCP lease file to route detection
This is an alternative to !8 (merged)
I created a new merge request that is just a slightly modified solution. The /var/lib/dhclient/$extif.routers file is managed by the /etc/dhcp/dhclient-exit-hooks.d/app-network.sh script. It's a programmatic way of getting the route - no complicated parsing required. However, if the file is empty, it will now fall back to the dhclient lease file parsing in Todd's merge request:
if (-e "/var/lib/dhclient/$extif.routers") {
$gateway = `/bin/cat /var/lib/dhclient/$extif.routers 2>/dev/null`;
chomp($gateway);
}
if (!$gateway) {
LogMsg("debug", $extif, "network - gateway not found in DHCP state file\n") if $config{debug};
$gateway = `tail -n 15 /var/lib/dhclient/dhclient*$extif.lease | grep routers | /bin/awk {\'print \$3\'} | tr -d ';'`;
chomp($gateway);
}
Edited by Peter B