aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/dnsmasq
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2014-05-20 05:00:28 +0000
committerFlorian Fainelli <florian@openwrt.org>2014-05-20 05:00:28 +0000
commite99cb3cbf6c6d0d166664c9c903a7352b3be2986 (patch)
treeb2db713254efdbc81a17e07256af83ef6145fd5e /package/network/services/dnsmasq
parent7fc54f8fb7f04ce8a44ba2313751ad32712f9c96 (diff)
downloadupstream-e99cb3cbf6c6d0d166664c9c903a7352b3be2986.tar.gz
upstream-e99cb3cbf6c6d0d166664c9c903a7352b3be2986.tar.bz2
upstream-e99cb3cbf6c6d0d166664c9c903a7352b3be2986.zip
dnsmasq: Allow creating static DNS entries from static lease entries
DHCP entries in /etc/config/dhcp will not automatically create A or PTR records. Add an "option dns" directive which appends an entry to /tmp/hosts/dhcp to facilitate forward and reverse DNS lookups. For instance, this item: config host option ip '192.168.0.10' option mac '00:13:57:9b:df:02' option name 'winpc' option dns '1' will add a corresponding entry to /tmp/hosts/dhcp: 192.168.0.10 winpc.lan This keeps the hostname/IP/MAC in a single place, for easy maintenance. Related: ticket #13854 reports an regression involving missing PTR records when using "config domain" to define static DNS entries for individual hosts. However, per Simon Kelley[1], the --address feature used by "config domain" was never intended to generate DNS A records for hosts. It would probably be better for the reporter to apply this patch, and then use "config host" sections instead of "config domain" sections. [1] http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2008q4/002498.html Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Florian Fainelli <florian@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@40799 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/services/dnsmasq')
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init7
1 files changed, 7 insertions, 0 deletions
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index b5fb58c524..f7edb28806 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -13,6 +13,7 @@ ADD_LOCAL_DOMAIN=1
ADD_LOCAL_HOSTNAME=1
CONFIGFILE="/var/etc/dnsmasq.conf"
+HOSTFILE="/tmp/hosts/dhcp"
xappend() {
local value="$1"
@@ -300,6 +301,11 @@ dhcp_host_add() {
[ "$broadcast" = "0" ] && broadcast=
xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}"
+
+ config_get_bool dns "$cfg" dns 0
+ [ "$dns" = "1" ] && {
+ echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE
+ }
}
dhcp_tag_add() {
@@ -528,6 +534,7 @@ start_service() {
mkdir -p $(dirname $CONFIGFILE)
echo "# auto-generated config file from /etc/config/dhcp" > $CONFIGFILE
+ echo "# auto-generated config file from /etc/config/dhcp" > $HOSTFILE
# if we did this last, we could override auto-generated config
[ -f /etc/dnsmasq.conf ] && {