]> git.ipfire.org Git - people/stevee/network.git/blobdiff - network
DNS: Add RDNSS functionality.
[people/stevee/network.git] / network
diff --git a/network b/network
index 3e6b09358f911627d11eacce509ad0a8cebb2982..808d2cd6f398f0939abff1eff3d618df84cf5dc4 100755 (executable)
--- a/network
+++ b/network
@@ -496,6 +496,9 @@ function cli_reset() {
                port_remove ${port}
        done
 
+       # Flush all DNS servers.
+       dns_server_flush
+
        # Re-run the initialization functions
        init_run
 
@@ -528,13 +531,59 @@ function cli_help() {
        hook_exec ${type} ${what} help
 }
 
+function cli_dns() {
+       if cli_help_requested $@; then
+               cli_show_man network-dns
+               exit ${EXIT_OK}
+       fi
+
+       # Get the command.
+       local cmd=${1}; shift
+       if [ -z "${cmd}" ]; then
+               cli_show_man network-dns
+               exit ${EXIT_ERROR}
+       fi
+
+       # Get the new server to process (if any).
+       local server=${1}
+       local priority=${2}
+
+       case "${cmd}" in
+               list)
+                       __dns_server_println "SERVER" "PRIORITY"
+                       dns_server_list
+                       exit ${EXIT_OK}
+                       ;;
+               add)
+                       log INFO "Adding new DNS server: ${server}"
+                       dns_server_add ${server} ${priority}
+                       ;;
+               remove)
+                       log INFO "Removing DNS server: ${server}"
+                       dns_server_remove ${server} ${priority}
+                       ;;
+               update)
+                       # Just run the update afterwards.
+                       ;;
+               *)
+                       error "No such command: ${cmd}"
+                       exit ${EXIT_ERROR}
+       esac
+
+       # Update the local DNS configuration after changes have been made.
+       dns_generate_resolvconf
+       radvd_update
+
+       exit ${EXIT_OK}
+}
+
 # Process the given action
 case "${action}" in
        init)
                init_run
                ;;
 
-       config|hostname|port|device|zone|start|stop|restart|status|reset)
+       config|hostname|port|device|zone|start|stop|restart|status|reset|dns)
                cli_${action} $@
                ;;