From 6411dbdc23e04d7c82c57d10f5488ff08217d13a Mon Sep 17 00:00:00 2001 From: Mohit Mehta Date: Sat, 30 Aug 2008 05:45:26 +0000 Subject: move from a 'ignore-interface' model to a 'listen-on' model for DNS forwarding --- scripts/dns-forwarding/vyatta-dns-forwarding.pl | 12 ++++++------ .../service/dns/forwarding/ignore-interface/node.def | 20 -------------------- templates/service/dns/forwarding/listen-on/node.def | 20 ++++++++++++++++++++ templates/service/dns/forwarding/node.def | 1 + 4 files changed, 27 insertions(+), 26 deletions(-) delete mode 100644 templates/service/dns/forwarding/ignore-interface/node.def create mode 100644 templates/service/dns/forwarding/listen-on/node.def diff --git a/scripts/dns-forwarding/vyatta-dns-forwarding.pl b/scripts/dns-forwarding/vyatta-dns-forwarding.pl index 73a4bbe4..c2ef968a 100644 --- a/scripts/dns-forwarding/vyatta-dns-forwarding.pl +++ b/scripts/dns-forwarding/vyatta-dns-forwarding.pl @@ -63,29 +63,29 @@ sub dnsforwarding_get_values { my $output = ''; my $config = new VyattaConfig; my $use_dnsmasq_conf = 0; - my (@ignore_interfaces, $cache_size, @use_nameservers, $use_system_nameservers, @use_dhcp_nameservers); + my (@listen_interfaces, $cache_size, @use_nameservers, $use_system_nameservers, @use_dhcp_nameservers); $config->setLevel("service dns forwarding"); if ($dhclient_script == 1){ $config->{_active_dir_base} = "/opt/vyatta/config/active/"; - @ignore_interfaces = $config->returnOrigValues("ignore-interface"); + @listen_interfaces = $config->returnOrigValues("listen-on"); $cache_size = $config->returnOrigValue("cache-size"); @use_nameservers = $config->returnOrigValues("name-server"); $use_system_nameservers = $config->existsOrig("system"); @use_dhcp_nameservers = $config->returnOrigValues("dhcp"); } else { - @ignore_interfaces = $config->returnValues("ignore-interface"); + @listen_interfaces = $config->returnValues("listen-on"); $cache_size = $config->returnValue("cache-size"); @use_nameservers = $config->returnValues("name-server"); $use_system_nameservers = $config->exists("system"); @use_dhcp_nameservers = $config->returnValues("dhcp"); } - if (@ignore_interfaces != 0) { - foreach my $interface (@ignore_interfaces) { - $output .= "except-interface=$interface\n"; + if (@listen_interfaces != 0) { + foreach my $interface (@listen_interfaces) { + $output .= "interface=$interface\n"; } } diff --git a/templates/service/dns/forwarding/ignore-interface/node.def b/templates/service/dns/forwarding/ignore-interface/node.def deleted file mode 100644 index 5bf20fa0..00000000 --- a/templates/service/dns/forwarding/ignore-interface/node.def +++ /dev/null @@ -1,20 +0,0 @@ -multi: -type: txt -help: Set interface to ignore DNS queries on -syntax:expression: exec " - intf_array=($(awk '$1 ~ /:/ { print $1 }' /proc/net/dev)) - intf_array_len=${#intf_array[*]} - i=0 - while [ $i -lt $intf_array_len ]; do - temp=${intf_array[$i]%:*} - if [ \"$temp\" == \"$VAR(@)\" ] ; then - exit 0 - fi - let i++ - done - echo Invalid ethernet interface [$VAR(@)] - exit 1 " - -allowed: local -a array ; - array=($(awk '$1 ~ /:/ { print $1 }' /proc/net/dev)); - echo -n ${array[@]%:*} diff --git a/templates/service/dns/forwarding/listen-on/node.def b/templates/service/dns/forwarding/listen-on/node.def new file mode 100644 index 00000000..9510cebe --- /dev/null +++ b/templates/service/dns/forwarding/listen-on/node.def @@ -0,0 +1,20 @@ +multi: +type: txt +help: Set interface to listen for DNS queries +syntax:expression: exec " + intf_array=($(awk '$1 ~ /:/ { print $1 }' /proc/net/dev)) + intf_array_len=${#intf_array[*]} + i=0 + while [ $i -lt $intf_array_len ]; do + temp=${intf_array[$i]%:*} + if [ \"$temp\" == \"$VAR(@)\" ] ; then + exit 0 + fi + let i++ + done + echo Invalid interface [$VAR(@)] + exit 1 " + +allowed: local -a array ; + array=($(awk '$1 ~ /:/ { print $1 }' /proc/net/dev)); + echo -n ${array[@]%:*} diff --git a/templates/service/dns/forwarding/node.def b/templates/service/dns/forwarding/node.def index 46dbd199..d3c32bb1 100644 --- a/templates/service/dns/forwarding/node.def +++ b/templates/service/dns/forwarding/node.def @@ -1,4 +1,5 @@ help: Configure DNS forwarding +commit:expression: $VAR(./listen-on) != ""; "Atleast one interface must be configured for DNS forwarding parameter 'listen-on'" delete:expression: "touch /tmp/dnsmasq.$PPID" end:expression: "if [ -f \"/tmp/dnsmasq.$PPID\" ]; then \ sudo /opt/vyatta/sbin/vyatta-dns-forwarding.pl --stop-dnsforwarding \ -- cgit v1.2.3