]> git.ipfire.org Git - people/ms/network.git/commitdiff
pppoe-server: Allow passing DNS servers to the client
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 6 Sep 2015 14:34:44 +0000 (14:34 +0000)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 6 Sep 2015 14:34:44 +0000 (14:34 +0000)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.pppoe-server
src/hooks/configs/pppoe-server
src/ppp/pppoe-server

index 02e4b9a0899032cfeb0a956f44815ebdcb67a034..2db743310d6d574b1bec48d93335114115e65cbc 100644 (file)
@@ -78,8 +78,8 @@ pppoe_server_options() {
                        --disable-ipv6)
                                ipv6="false"
                                ;;
-                       --dns-server=*)
-                               dns_servers="${dns_servers} $(cli_get_val ${1})"
+                       --dns-servers=*)
+                               dns_servers="$(cli_get_val ${1})"
                                ;;
                        --lcp-echo-failure=*)
                                lcp_echo_failure=$(cli_get_val ${1})
index d952ecc24b9f237b81040658d0af14aaedbe8177..1ef3ba9c5208ecbef1a262a9bdfa7be57546ea0c 100644 (file)
@@ -21,7 +21,7 @@
 
 . /usr/lib/network/header-config
 
-HOOK_CONFIG_SETTINGS="HOOK MTU SERVICE_NAME SUBNET MAX_SESSIONS"
+HOOK_CONFIG_SETTINGS="HOOK DNS_SERVERS MTU SERVICE_NAME SUBNET MAX_SESSIONS"
 
 # Maximum Transmission Unit.
 MTU=1492
@@ -41,6 +41,11 @@ hook_check_config_settings() {
        assert isset MTU
        assert isset SUBNET
        assert isset MAX_SESSIONS
+
+       local server
+       for server in ${DNS_SERVERS}; do
+               assert ipv4_is_valid "${server}"
+       done
 }
 
 hook_new() {
@@ -49,6 +54,19 @@ hook_new() {
 
        while [ $# -gt 0 ]; do
                case "${1}" in
+                       --dns-server=*)
+                               local dns_servers="$(cli_get_val "${1}")"
+
+                               local dns_server
+                               for dns_server in ${dns_servers}; do
+                                       if ! ipv4_is_valid "${dns_server}"; then
+                                               warning  "Invalid IPv4 address: ${dns_server}. Skipped."
+                                               continue
+                                       fi
+
+                                       list_append DNS_SERVERS "${dns_server}"
+                               done
+                               ;;
                        --max-sessions=*)
                                MAX_SESSIONS=$(cli_get_val ${1})
                                ;;
index 75dac188d3561c0163c911e12583c18fd0dbf219..96814653226058ba70aaa6866f441ecdb71932b8 100644 (file)
@@ -75,7 +75,8 @@ case "${action}" in
                fi
 
                # Create the pppoe-server-options file.
-               pppoe_server_options ${pppd_options} ${zone}
+               pppoe_server_options ${pppd_options} ${zone} \
+                       --dns-servers="${DNS_SERVERS}"
                pppoe_cmdline="${pppoe_cmdline} -O ${pppd_options}"
 
                # Configure the IP addresses.