diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-01-12 10:17:48 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-01-12 12:14:20 +0100 |
commit | ec63e3bf1312ab4c666f7417ca9844857214047f (patch) | |
tree | 2b770ce1b13b9141395a9316dcfc418c97102e62 /package/network/services | |
parent | bb8e9c51ab457b0bc010b47ceeab8c0e4f0d6a67 (diff) | |
download | upstream-ec63e3bf1312ab4c666f7417ca9844857214047f.tar.gz upstream-ec63e3bf1312ab4c666f7417ca9844857214047f.tar.bz2 upstream-ec63e3bf1312ab4c666f7417ca9844857214047f.zip |
Revert "dnsmasq: change 'add_local_hostname' to use dnsmasq '--interface-name'"
This causes problem when a FQDN is configured in /etc/config/system. The
domain name will appear twice in reverse DNS.
Next to that, there seems to be a bug in dnsmasq. From the manual page:
--interface-name=<name>,<interface>[/4|/6]
Return a DNS record associating the name with the primary address
on the given interface. This flag specifies an A or AAAA record for the
given name in the same way as an /etc/hosts line, except that the address
is not constant, but taken from the given interface. The interface may be
followed by "/4" or "/6" to specify that only IPv4 or IPv6 addresses
of the interface should be used. If the interface is down, not configured
or non-existent, an empty record is returned. The matching PTR record is
also created, mapping the interface address to the name. More than one name
may be associated with an interface address by repeating the flag; in that
case the first instance is used for the reverse address-to-name mapping.
It does not just create an A/AAAA record for the primary address, it creates
one for all addresses. And what is worse, it seems to actually resolve to the
non-primary address first. This is quite annoying when you use floating IP
addresses (e.g. VRRP), because when the floating IP is on the other device,
SSH failes due to incorrect entry in the known hosts file.
I know that this is not a common setup, but it would be nice if there was an
option to restore the previous behaviour, rather than just forcing this new
feature on everybody.
Reported-by: Stijn Tintel <stijn@linux-ipv6.be>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'package/network/services')
-rw-r--r-- | package/network/services/dnsmasq/Makefile | 2 | ||||
-rw-r--r-- | package/network/services/dnsmasq/files/dnsmasq.init | 52 |
2 files changed, 23 insertions, 31 deletions
diff --git a/package/network/services/dnsmasq/Makefile b/package/network/services/dnsmasq/Makefile index 98333850af..bbcda9afb7 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:=7 +PKG_RELEASE:=6 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 87332a9081..46607dfe25 100644 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -8,7 +8,6 @@ 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" @@ -294,26 +293,6 @@ 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" @@ -384,11 +363,7 @@ dhcp_add() { DNS_SERVERS="$DNS_SERVERS $dnsserver" } - 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 - } + append_bool "$cfg" ignore "--no-dhcp-interface=$ifname" && return 0 # Do not support non-static interfaces for now [ static = "$proto" ] || return 0 @@ -406,9 +381,6 @@ 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}" @@ -633,7 +605,6 @@ 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 @@ -731,6 +702,27 @@ 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" |