From c3485245640f29c0eabc40aebad5ec6dfe54cf15 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 11 Oct 2015 17:05:40 +0100 Subject: Add /usr/local/sbin/ppp-ipv6 helper script /usr/local/sbin/ppp-ipv6 up|down Interface using SLAAC or DHCP6 going down: * bring down dhcp6c if it is running * disable router advertisements (and therefore SLAAC) * remove any autoconfigured IPv6 addresses Interface using SLAAC or DHCP6 coming up: * call interface_dhcpv6_configure() if dhcp6c not running and router advertisements off interface_dhcpv6_configure() will enable router advertisements, configure rtsold and dhcp6c, then set rtsold to prime dhcp6c as required. --- usr/local/sbin/ppp-ipv6 | 123 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100755 usr/local/sbin/ppp-ipv6 (limited to 'usr/local') diff --git a/usr/local/sbin/ppp-ipv6 b/usr/local/sbin/ppp-ipv6 new file mode 100755 index 0000000..a05a4c2 --- /dev/null +++ b/usr/local/sbin/ppp-ipv6 @@ -0,0 +1,123 @@ +#!/usr/local/bin/php -f + up|down\n"); +} +exit(1); + +?> -- cgit v1.1 From 37803aa5ba08e5715f2c3497947e22e2815adacf Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 11 Oct 2015 17:23:04 +0100 Subject: Connect ppp-ipv6 helper script to ppp-linkdown and ppp-linkup --- usr/local/sbin/ppp-linkdown | 4 ++++ usr/local/sbin/ppp-linkup | 1 + 2 files changed, 5 insertions(+) (limited to 'usr/local') diff --git a/usr/local/sbin/ppp-linkdown b/usr/local/sbin/ppp-linkdown index 62d07ed..94e72d0 100755 --- a/usr/local/sbin/ppp-linkdown +++ b/usr/local/sbin/ppp-linkdown @@ -1,6 +1,7 @@ #!/bin/sh IF="${1}" +PROTOCOL="${2}" LOCAL_IP="${3}" if [ -f /tmp/${IF}up ] && [ -f /conf/${IF}.log ]; then @@ -15,6 +16,9 @@ if [ -s "/tmp/${IF}_defaultgw" ]; then [ -n "${GW}" ] \ && /sbin/route delete default ${GW} fi +if [ "${PROTOCOL}" == "inet6" ]; then + /usr/local/sbin/ppp-ipv6 ${IF} down +fi # delete the node just in case mpd cannot do that /usr/sbin/ngctl shutdown ${IF}: if [ -f "/var/etc/nameserver_${IF}" ]; then diff --git a/usr/local/sbin/ppp-linkup b/usr/local/sbin/ppp-linkup index 2d1eb33..35ed0d2 100755 --- a/usr/local/sbin/ppp-linkup +++ b/usr/local/sbin/ppp-linkup @@ -35,6 +35,7 @@ if [ "${2}" == "inet" ]; then pfSctl -c "interface newip ${1}" elif [ "${2}" == "inet6" ]; then + /usr/local/sbin/ppp-ipv6 ${1} up # let the configuration system know that the ipv6 has changed. echo ${4} |cut -d% -f1 > /tmp/${1}_routerv6 echo ${3} |cut -d% -f1 > /tmp/${1}_ipv6 -- cgit v1.1 From f190f1a07919957b66b800392ec5c7bb6b44d756 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 11 Oct 2015 17:39:37 +0100 Subject: Make code dealing with the IPv4 default gateway conditional on the IPv4 link going down --- usr/local/sbin/ppp-linkdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr/local') diff --git a/usr/local/sbin/ppp-linkdown b/usr/local/sbin/ppp-linkdown index 94e72d0..428fa42 100755 --- a/usr/local/sbin/ppp-linkdown +++ b/usr/local/sbin/ppp-linkdown @@ -11,7 +11,7 @@ fi /etc/rc.kill_states ${IF} ${LOCAL_IP} -if [ -s "/tmp/${IF}_defaultgw" ]; then +if [ "${PROTOCOL}" == "inet" && -s "/tmp/${IF}_defaultgw" ]; then GW=`head -n 1 /tmp/${IF}_defaultgw` [ -n "${GW}" ] \ && /sbin/route delete default ${GW} -- cgit v1.1 From 0c54b7567b75798a201483ce55ca648dbe8a1d0d Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 11 Oct 2015 17:42:14 +0100 Subject: Make route deletions quiet - it may well be the routes have already disappeared --- usr/local/sbin/ppp-linkdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'usr/local') diff --git a/usr/local/sbin/ppp-linkdown b/usr/local/sbin/ppp-linkdown index 428fa42..6fca066 100755 --- a/usr/local/sbin/ppp-linkdown +++ b/usr/local/sbin/ppp-linkdown @@ -14,7 +14,7 @@ fi if [ "${PROTOCOL}" == "inet" && -s "/tmp/${IF}_defaultgw" ]; then GW=`head -n 1 /tmp/${IF}_defaultgw` [ -n "${GW}" ] \ - && /sbin/route delete default ${GW} + && /sbin/route -q delete default ${GW} fi if [ "${PROTOCOL}" == "inet6" ]; then /usr/local/sbin/ppp-ipv6 ${IF} down @@ -24,7 +24,7 @@ fi if [ -f "/var/etc/nameserver_${IF}" ]; then # Remove old entries for nameserver in `cat /var/etc/nameserver_${IF}`; do - /sbin/route delete ${nameserver} >/dev/null 2>&1 + /sbin/route -q delete ${nameserver} >/dev/null 2>&1 done /bin/rm -f /var/etc/nameserver_${IF} fi -- cgit v1.1 From a7cc117f3e4f2d85eb098ed4acf52720a37cdc6b Mon Sep 17 00:00:00 2001 From: David Wood Date: Sun, 11 Oct 2015 17:49:15 +0100 Subject: Use named variables for ppp-linkup command line parameters --- usr/local/sbin/ppp-linkup | 72 ++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 32 deletions(-) (limited to 'usr/local') diff --git a/usr/local/sbin/ppp-linkup b/usr/local/sbin/ppp-linkup index 35ed0d2..002af74 100755 --- a/usr/local/sbin/ppp-linkup +++ b/usr/local/sbin/ppp-linkup @@ -2,62 +2,70 @@ export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin -if [ "${2}" == "inet" ]; then +IF="${1}" +PROTOCOL="${2}" +LOCAL_IP="${3}" +REMOTE_IP="${4}" +AUTH_NAME="${5}" +DNS1_RAW="${6}" +DNS2_RAW="${7}" - OLD_ROUTER=`cat /tmp/${1}_router` +if [ "${PROTOCOL}" == "inet" ]; then + + OLD_ROUTER=`cat /tmp/${IF}_router` if [ -n "${OLD_ROUTER}" ]; then echo "Removing states to old router ${OLD_ROUTER}" | logger -t ppp-linkup - pfctl -i ${1} -k 0.0.0.0/0 -k ${OLD_ROUTER}/32 - pfctl -i ${1} -k ${OLD_ROUTER}/32 -k 0.0.0.0/0 + pfctl -i ${IF} -k 0.0.0.0/0 -k ${OLD_ROUTER}/32 + pfctl -i ${IF} -k ${OLD_ROUTER}/32 -k 0.0.0.0/0 fi # let the configuration system know that the ipv4 has changed. - echo ${4} > /tmp/${1}_router - echo ${3} > /tmp/${1}_ip - touch /tmp/${1}up + echo ${REMOTE_IP} > /tmp/${IF}_router + echo ${LOCAL_IP} > /tmp/${IF}_ip + touch /tmp/${IF}up if grep -q dnsallowoverride /conf/config.xml; then # write nameservers to file - echo -n "" > /var/etc/nameserver_${1} - if echo "${6}" | grep -q dns1; then - DNS1=`echo "${6}" | awk '{print $2}'` - echo "${DNS1}" >> /var/etc/nameserver_${1} - route change "${DNS1}" ${4} + echo -n "" > /var/etc/nameserver_${IF} + if echo "${DNS1_RAW}" | grep -q dns1; then + DNS1=`echo "${DNS1_RAW}" | awk '{print $2}'` + echo "${DNS1}" >> /var/etc/nameserver_${IF} + route change "${DNS1}" ${REMOTE_IP} fi - if echo "${7}" | grep -q dns2; then - DNS2=`echo "${7}" | awk '{print $2}'` - echo "${DNS2}" >> /var/etc/nameserver_${1} - route change "${DNS2}" ${4} + if echo "${DNS2_RAW}" | grep -q dns2; then + DNS2=`echo "${DNS2_RAW}" | awk '{print $2}'` + echo "${DNS2}" >> /var/etc/nameserver_${IF} + route change "${DNS2}" ${REMOTE_IP} fi pfSctl -c 'service reload dns' sleep 1 fi - pfSctl -c "interface newip ${1}" + pfSctl -c "interface newip ${IF}" -elif [ "${2}" == "inet6" ]; then - /usr/local/sbin/ppp-ipv6 ${1} up +elif [ "${PROTOCOL}" == "inet6" ]; then + /usr/local/sbin/ppp-ipv6 ${IF} up # let the configuration system know that the ipv6 has changed. - echo ${4} |cut -d% -f1 > /tmp/${1}_routerv6 - echo ${3} |cut -d% -f1 > /tmp/${1}_ipv6 - touch /tmp/${1}upv6 + echo ${REMOTE_IP} |cut -d% -f1 > /tmp/${IF}_routerv6 + echo ${LOCAL_IP} |cut -d% -f1 > /tmp/${IF}_ipv6 + touch /tmp/${IF}upv6 if grep -q dnsallowoverride /conf/config.xml; then # write nameservers to file - echo -n "" > /var/etc/nameserver_v6${1} - if echo "${6}" | grep -q dns1; then - DNS1=`echo "${6}" | awk '{print $2}'` - echo "${DNS1}" >> /var/etc/nameserver_v6${1} - route change -inet6 "${DNS1}" ${4} + echo -n "" > /var/etc/nameserver_v6${IF} + if echo "${DNS1_RAW}" | grep -q dns1; then + DNS1=`echo "${DNS1_RAW}" | awk '{print $2}'` + echo "${DNS1}" >> /var/etc/nameserver_v6${IF} + route change -inet6 "${DNS1}" ${REMOTE_IP} fi - if echo "${7}" | grep -q dns2; then - DNS2=`echo "${7}" | awk '{print $2}'` - echo "${DNS2}" >> /var/etc/nameserver_v6${1} - route change -inet6 "${DNS2}" ${4} + if echo "${DNS2_RAW}" | grep -q dns2; then + DNS2=`echo "${DNS2_RAW}" | awk '{print $2}'` + echo "${DNS2}" >> /var/etc/nameserver_v6${IF} + route change -inet6 "${DNS2}" ${REMOTE_IP} fi pfSctl -c 'service reload dns' sleep 1 fi - pfSctl -c "interface newipv6 ${1}" + pfSctl -c "interface newipv6 ${IF}" fi exit 0 -- cgit v1.1