Reply To: Multiple WAN interfaces and Dynamic DNS

Home Page Forums Network Management ZeroShell Multiple WAN interfaces and Dynamic DNS Reply To: Multiple WAN interfaces and Dynamic DNS

#50510

aviegas
Member

I’m send Fulvio an email.

Also, as I said, I been doing some testing and I’ve found 2 small problems.

1) The code I wrote to get the gw ip address was testing if the ethernet interface was DHCP based and if the interface was active. It turns out that the “if active” test causes a minor glitch in “routeupd” as it expects the old gateway IP to be able to properly remove the route. This is hard to notice because “failoverd” will eventually correct the problem.

The fixed version for my nb_getgwip is:

#!/bin/sh
. /etc/kerbynet.conf
GW="$1"
IP=`cat $GW/IP 2>/dev/null`
if [ -z "$IP" ] ; then
INTERFACE=`cat $GW/Interface 2>/dev/null`
if [ -n "$INTERFACE" ] ; then
DHCP="$REGISTER/system/net/interfaces/$INTERFACE/dhclient"
IP=`cat $DHCP/leases 2>/dev/null | grep routers | awk 'END{sub(/;/,"") ; print $3}'`
fi
fi
echo $IP

2) nb_setnexthop has an odd behavior when deleting the existing default routes (just before adding the new ones). When a DHCP interface comes up, dhcpclient will add a standard default route for the newly aquired configuration. Like the previous state it needs to be purged to allow for the correct “nexthop” entry. It turns out that a single “ip ro del default” command only deletes the newly added DHCP route, leaving any other route there. This will cause the “ip ro add default $NEXTHOP” to fail and the routes to remain invalid. The solution here is simple: just add an extra “ip ro del defaul”. Doing it twice ensure that the default route is not set, as required.

The code near the end of nb_setnexthop must read:

...
if [ "$CHANGE" = yes ] ; then
ip ro del default 2>/dev/null
ip ro del default 2>/dev/null # Required to really delete in some cases, or add will not work correctly
/usr/latest/ip ro add default $NEXTHOP
echo $ACTIVEGW > /tmp/nb/ActiveGW
logger -t NetBalancer "Default Route has been changed: $NEXTHOP"
else
....

I’ve tried several combinations of faults and it seems to be working fine.