aboutsummaryrefslogtreecommitdiffstats
path: root/package/network
diff options
context:
space:
mode:
authorEric Luehrsen <ericluehrsen@hotmail.com>2016-12-20 22:08:54 -0500
committerHans Dedecker <dedeckeh@gmail.com>2017-01-05 22:51:39 +0100
commit612e2276b4a2f57fcbbe79b95bec4a46e89d748c (patch)
treed3021c1625b7ed7e8f404e70cd289e8143866592 /package/network
parent06e26363d89788b536e5f2317ec19288c4f6b805 (diff)
downloadupstream-612e2276b4a2f57fcbbe79b95bec4a46e89d748c.tar.gz
upstream-612e2276b4a2f57fcbbe79b95bec4a46e89d748c.tar.bz2
upstream-612e2276b4a2f57fcbbe79b95bec4a46e89d748c.zip
dnsmasq: change 'add_local_hostname' to use dnsmasq '--interface-name'
'add_local_hostname' previous implementation may drop some addresses. Soft addition of IP6 addresses may not cause a reload or restart event. dnsmasq '--interface-name' robustly applies DNS to all addresses per interface (except fe80::/10). Change UCI 'add_local_hostname' to expand during each interface assignement during add_dhcp(). Assign '<iface>.<host>.<domain>' as true name (reflexive A, AAAA, and PTR). Assign '<host>.<domain>' and '<host>' as convinience aliases (no PTR, not technically CNAME). This is accomplished with the '--interface-name' order, first is PTR. We could also assign each <ip4/6>.<iface>.<host>.<domain> to the respective dual stack on the interface. That seemed excessive so it was skipped (/4 or /6 suffix to the interface). Add UCI 'add_wan_hostname' similar to 'add_local_hostname' function for external WAN. WAN IP4 are less often named by the ISP and rarely WAN IP6 due to complexity. For logs, LuCI connection graph, and other uses assigning a WAN name is desired. 'add_local_hostname' only applies with DHCP and 'add_wam_hostname' only applies without DHCP. Common residential users will want to set both options TRUE. Businesses will probably have global DNS, static IP, and 'add_wan_hostname' FALSE. Signed-off-by: Eric Luehrsen <ericluehrsen@hotmail.com>
Diffstat (limited to 'package/network')
-rw-r--r--package/network/services/dnsmasq/Makefile2
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init52
2 files changed, 31 insertions, 23 deletions
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile
index bbcda9afb7..98333850af 100644
--- a/package/network/services/dnsmasq/Makefile
+++ b/package/network/services/dnsmasq/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dnsmasq
PKG_VERSION:=2.76
-PKG_RELEASE:=6
+PKG_RELEASE:=7
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 46607dfe25..87332a9081 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -8,6 +8,7 @@ PROG=/usr/sbin/dnsmasq
ADD_LOCAL_DOMAIN=1
ADD_LOCAL_HOSTNAME=1
+ADD_WAN_HOSTNAME=0
BASECONFIGFILE="/var/etc/dnsmasq.conf"
BASEHOSTFILE="/tmp/hosts/dhcp"
@@ -293,6 +294,26 @@ dhcp_host_add() {
xappend "--dhcp-host=$macs${duid:+,id:$duid}${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}"
}
+dhcp_this_host_add() {
+ # TODO: case-in do/not short-host or FQDN; UCI already intended ...
+ local ifname="$1"
+ local do_enable="$2"
+ local routerstub routername ifdashname
+
+
+ if [ "$do_enable" -gt 0 ] ; then
+ # All IP addresses discovered by dnsmasq will be labeled robustly (except fe80::)
+ ifdashname="${ifname//./-}"
+ routerstub="$( md5sum /etc/os-release )"
+ routerstub="router-${routerstub// */}"
+ routername="$( uci_get system @system[0] hostname $routerstub )"
+
+ xappend "--interface-name=$ifdashname.$routername.$DOMAIN,$ifname"
+ xappend "--interface-name=$routername.$DOMAIN,$ifname"
+ xappend "--interface-name=$routername,$ifname"
+ fi
+}
+
dhcp_tag_add() {
local cfg="$1"
@@ -363,7 +384,11 @@ dhcp_add() {
DNS_SERVERS="$DNS_SERVERS $dnsserver"
}
- append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0
+ append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && {
+ # Many ISP do not have useful names for DHCP customers (your WAN).
+ dhcp_this_host_add $ifname $ADD_WAN_HOSTNAME
+ return 0
+ }
# Do not support non-static interfaces for now
[ static = "$proto" ] || return 0
@@ -381,6 +406,9 @@ dhcp_add() {
config_get options "$cfg" options
config_get_bool dynamicdhcp "$cfg" dynamicdhcp 1
+ # Put the router host name on this DHCP served interface address(es)
+ dhcp_this_host_add $ifname $ADD_LOCAL_HOSTNAME
+
leasetime="${leasetime:-12h}"
start="$(dhcp_calc "${start:-100}")"
limit="${limit:-150}"
@@ -605,6 +633,7 @@ dnsmasq_start()
config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1
config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1
+ config_get_bool ADD_WAN_HOSTNAME "$cfg" add_wan_hostname 0
config_get_bool readethers "$cfg" readethers
[ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
@@ -702,27 +731,6 @@ dnsmasq_start()
config_foreach filter_dnsmasq hostrecord dhcp_hostrecord_add "$cfg"
config_foreach filter_dnsmasq relay dhcp_relay_add "$cfg"
- # add own hostname
- [ $ADD_LOCAL_HOSTNAME -eq 1 ] && {
- local lanaddr lanaddr6
- local ulaprefix="$(uci_get network @globals[0] ula_prefix)"
- local hostname="$(uci_get system @system[0] hostname Lede)"
-
- network_get_ipaddr lanaddr "lan" && {
- dhcp_domain_add "" "$hostname" "$lanaddr"
- }
-
- [ -n "$ulaprefix" ] && network_get_ipaddrs6 lanaddr6 "lan" && {
- for lanaddr6 in $lanaddr6; do
- case "$lanaddr6" in
- "${ulaprefix%%:/*}"*)
- dhcp_domain_add "" "$hostname" "$lanaddr6"
- ;;
- esac
- done
- }
- }
-
echo >> $CONFIGFILE_TMP
config_foreach filter_dnsmasq srvhost dhcp_srv_add "$cfg"
config_foreach filter_dnsmasq mxhost dhcp_mx_add "$cfg"