core/src/opnsense/scripts/interfaces/ppp-linkdown.sh
Franco Fichtner 26ccc7839f system: remove _defaultgw(v6) file handling; closes #5900
Try to avoid touching default routes in dhclient-script which we
already partially do now.  PPPoE linkdown certainly doesn't need
to handle the file as well to remove the default route then.
2022-10-06 09:29:12 +02:00

40 lines
995 B
Bash
Executable File

#!/bin/sh
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
IF="${1}"
AF="${2}"
IP="${3}"
GW=
DEFAULTGW=$(route -n get -${AF} default | grep gateway: | awk '{print $2}')
ngctl shutdown ${IF}:
if [ "${AF}" = "inet" ]; then
/usr/local/sbin/ifctl -i ${IF} -4nd
/usr/local/sbin/ifctl -i ${IF} -4rd
/usr/local/sbin/configctl -d interface newip ${IF}
elif [ "${AF}" = "inet6" ]; then
# remove previous SLAAC addresses as the ISP may
# not respond to these in the upcoming session
ifconfig ${IF} | grep -e autoconf -e deprecated | while read FAMILY ADDR MORE; do
ifconfig ${IF} ${FAMILY} ${ADDR} -alias
done
/usr/local/sbin/ifctl -i ${IF} -6nd
/usr/local/sbin/ifctl -i ${IF} -6rd
/usr/local/sbin/configctl -d interface newipv6 ${IF}
fi
UPTIME=$(/usr/local/opnsense/scripts/interfaces/ppp-uptime.sh ${IF})
if [ -n "${UPTIME}" -a -f "/conf/${IF}.log" ]; then
echo $(date -j +%Y.%m.%d-%H:%M:%S) ${UPTIME} >> /conf/${IF}.log
fi
rm -f /tmp/${IF}_uptime
exit 0