diff --git a/src/man/man8/ifctl.8 b/src/man/man8/ifctl.8 index 83d478740..991e1b5d1 100644 --- a/src/man/man8/ifctl.8 +++ b/src/man/man8/ifctl.8 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 22, 2022 +.Dd July 25, 2022 .Dt IFCTL 8 .Os .Sh NAME @@ -41,12 +41,22 @@ The .Nm utility will display or modify network device related data used by dynamic connections. -If one of +.Pp +If none of .Sq Fl c , .Sq Fl d or .Sq Fl a are given the current data is returned instead of modifying it. +In this case a special interface suffix +.Sq :slaac +is supported as a fallback option and read if no data file was found +for the exact interface match. +During modification using any option mentioned above, however, the +.Sq :slaac +suffix must be given explicitly through the +.Sq Fl i +parameter. .Pp The options are as follows: .Bl -tag -width ".Fl i Ar interface" -offset indent @@ -70,6 +80,10 @@ Delete the specified data of the selected device. Select the .Ar device to operate on. +Special suffix +.Sq :slaac +given creates a fallback configuration file only to be read +if no exact match for the selected interface exists. If none was given .Nm list the available devices. diff --git a/src/opnsense/scripts/interfaces/nameserver.sh b/src/opnsense/scripts/interfaces/nameserver.sh index 4edc90808..5832b8693 100755 --- a/src/opnsense/scripts/interfaces/nameserver.sh +++ b/src/opnsense/scripts/interfaces/nameserver.sh @@ -58,10 +58,10 @@ while getopts 46a:cdi:lnprsV OPT; do EX=v6 ;; a) - DO_COMMAND="-a" DO_CONTENTS="${DO_CONTENTS} ${OPTARG}" ;; c) + DO_COMMAND="-c" MD="nameserver prefix router searchdomain" ;; d) @@ -107,9 +107,11 @@ if [ "${DO_COMMAND}" = "-c" ]; then # iterate through possible files for MD in nameserver prefix router searchdomain; do - FILE="/tmp/${IF}_${MD}${EX}" - flush_routes - rm -f ${FILE} + for IFC in ${IF} ${IF}:slaac; do + FILE="/tmp/${IFC}_${MD}${EX}" + flush_routes + rm -f ${FILE} + done done exit 0 @@ -138,11 +140,22 @@ fi if [ "${DO_COMMAND}" = "-d" ]; then flush_routes rm -f ${FILE} -elif [ "${DO_COMMAND}" = "-a" ]; then - for CONTENT in ${DO_CONTENTS}; do - echo "${CONTENT}" >> ${FILE} - done +fi + +for CONTENT in ${DO_CONTENTS}; do + echo "${CONTENT}" >> ${FILE} +done + +if [ -n "${DO_COMMAND}${DO_CONTENT}" ]; then + exit 0 +fi + +if [ ! -f ${FILE} ]; then + # move to :slaac interface suffix if not found + FILE="/tmp/${IF}:slaac_${MD}${EX}" +fi + # if nothing else could be done display data -elif [ -f ${FILE} ]; then +if [ -f ${FILE} ]; then cat ${FILE} fi diff --git a/src/opnsense/scripts/interfaces/rtsold_resolvconf.sh b/src/opnsense/scripts/interfaces/rtsold_resolvconf.sh index d3546c7a8..f6da0f267 100755 --- a/src/opnsense/scripts/interfaces/rtsold_resolvconf.sh +++ b/src/opnsense/scripts/interfaces/rtsold_resolvconf.sh @@ -33,25 +33,16 @@ if [ -z "${2}" ]; then fi # ${2} is 'ifname:slaac:[RA-source-address]', where 'ifname' is the -# interface the RA was received on. +# interface the RA was received on. Keep the ":slaac" suffix to create +# an interface fallback configuration handled through ifctl(8) utility. -ifname=${2%%:*} -rasrca=${2##*:slaac:[} +ifname=${2%%:[*} +rasrca=${2##*:[} rasrca=${rasrca%]} -# XXX replace by exlusive 'ifname:slaac' use and falling back internally in ifctl? -if [ -n "$(/usr/local/sbin/ifctl -i ${ifname} -6r)" ]; then - echo "IPv6 gateway for ${ifname} already exists." - exit 0 -fi - # ${1} indicates whether DNS information should be added or deleted. if [ "${1}" = "-a" ]; then - /usr/local/sbin/ifctl -i ${ifname} -6rd -a ${rasrca} - # XXX stop modifying defaultgw files in scripts - echo ${rasrca} > /tmp/${ifname}_defaultgwv6 - # rtsold sends a resolv.conf(5) file to STDIN of this script while IFS=' ' read -r type value; do if [ "${type}" = "nameserver" ]; then @@ -71,7 +62,14 @@ if [ "${1}" = "-a" ]; then /usr/local/sbin/ifctl -i ${ifname} -6nd ${nameservers} /usr/local/sbin/ifctl -i ${ifname} -6sd ${searchlist} - /usr/local/sbin/configctl -d interface newipv6 ${ifname} -fi + /usr/local/sbin/ifctl -i ${ifname} -6rd -a ${rasrca} -# XXX implement -d as well + # remove slaac suffix here to reload correct interface + /usr/local/sbin/configctl -d interface newipv6 ${ifname%%:slaac} +elif [ "${1}" = "-d" ]; then + /usr/local/sbin/ifctl -i ${ifname} -6nd + /usr/local/sbin/ifctl -i ${ifname} -6sd + + # reload DNS since data has been scrubbed + /usr/local/sbin/configctl -d dns reload +fi