diff --git a/src/man/man8/ifctl.8 b/src/man/man8/ifctl.8 index 991e1b5d1..211d5d85b 100644 --- a/src/man/man8/ifctl.8 +++ b/src/man/man8/ifctl.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 2022 Franco Fichtner +.\" Copyright (c) 2022-2023 Franco Fichtner .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 25, 2022 +.Dd August 29, 2023 .Dt IFCTL 8 .Os .Sh NAME @@ -35,7 +35,7 @@ .Op Fl i Ar device .Op Fl 46 .Op Fl nprs -.Op Fl a Ar data | Fl c | Fl d | Fl l +.Op Fl a Ar data | Fl c | Fl d | Fl l | Fl O .Sh DESCRIPTION The .Nm @@ -95,6 +95,11 @@ not using the interface option .It Fl n Use name server mode. This is the default. +.It Fl O +Dump mode is similar to +.Sq Fl l , +but prints all the available file names and their data for the +specified interface. .It Fl p Use prefix delegation mode. .It Fl r diff --git a/src/opnsense/scripts/interfaces/ifctl.sh b/src/opnsense/scripts/interfaces/ifctl.sh index 4ab275322..b64cc9cdc 100755 --- a/src/opnsense/scripts/interfaces/ifctl.sh +++ b/src/opnsense/scripts/interfaces/ifctl.sh @@ -27,6 +27,8 @@ DO_COMMAND= DO_CONTENTS= DO_VERBOSE= +FILES="nameserver prefix router searchdomain" + AF= MD= EX= @@ -55,7 +57,7 @@ flush_routes() # default to IPv4 with nameserver mode set -- -4 -n ${@} -while getopts 46a:cdi:lnprsV OPT; do +while getopts 46a:cdi:lnOprsV OPT; do case ${OPT} in 4) AF=inet @@ -70,7 +72,7 @@ while getopts 46a:cdi:lnprsV OPT; do ;; c) DO_COMMAND="-c" - MD="nameserver prefix router searchdomain" + MD="${FILES}" ;; d) DO_COMMAND="-d" @@ -84,6 +86,9 @@ while getopts 46a:cdi:lnprsV OPT; do n) MD="nameserver" ;; + O) + DO_COMMAND="-O" + ;; p) MD="prefix" ;; @@ -116,7 +121,7 @@ if [ "${DO_COMMAND}" = "-c" ]; then HAVE_ROUTE= # iterate through possible files for cleanup - for MD in nameserver prefix router searchdomain; do + for MD in ${FILES}; do for IFC in ${IF} ${IF}:slaac; do FILE="/tmp/${IFC}_${MD}${EX}" if [ ! -f ${FILE} ]; then @@ -138,6 +143,30 @@ if [ "${DO_COMMAND}" = "-c" ]; then /sbin/pfctl -i ${IF} -Fs fi + exit 0 +elif [ "${DO_COMMAND}" = "-O" ]; then + if [ -z "${IF}" ]; then + echo "Dumping requires interface option" >&2 + exit 1 + fi + + # iterate through possible files to print its data (ignore -4/6) + for EX in '' v6; do + for MD in ${FILES}; do + for IFC in ${IF} ${IF}:slaac; do + FILE="/tmp/${IFC}_${MD}${EX}" + if [ ! -f ${FILE} ]; then + continue + fi + echo -n "${FILE}:" + for CONTENT in $(cat ${FILE}); do + echo -n " ${CONTENT}" + done + echo + done + done + done + exit 0 elif [ "${DO_COMMAND}" = "-l" ]; then if [ -z "${IF}" ]; then