Modify

Opened 12 years ago

Closed 12 years ago

#177 closed defect (fixed)

[patch] make dnsmasq and do_ifup use /tmp/resolv.conf directly

Reported by: danversj Owned by: developers
Priority: normal Milestone:
Component: base system Version: 2.0
Keywords: networking hotplug Cc:

Description

This is a patch to point dnsmasq and the do_ifup function directly at /tmp/resolv.conf. The patch is against kamikaze-trunk.

This makes it easy to use dnsmasq for local name resolution. With this patch in place, you can delete the /etc/resolv.conf -> /tmp/resolv.conf symlink. Dnsmasq, do_ifup and the udhcpc default.script will all continue to use /tmp/resolv.conf normally. You create a new /etc/resolv.conf and put "nameserver 127.0.0.1" in it to make OpenWRT use dnsmasq as it's name resolver. By doing so you can locally resolve the contents of any hosts files plus the hostnames of any dhcp clients, plus the upstream nameservers contained in /tmp/resolv.conf.

If you don't want to do this, or if you're not running dnsmasq, you can just leave the /etc/resolv.conf symlink in place and everything will be as normal.

diff -ur openwrt/package/base-files/default/etc/hotplug.d/net/10-net openwrt-mod/package/base-files/default/etc/hotplug.d/net/10-net
--- openwrt/package/base-files/default/etc/hotplug.d/net/10-net    2006-01-02 15:30:11.904360000 +1100
+++ openwrt-mod/package/base-files/default/etc/hotplug.d/net/10-net    2006-01-02 16:01:46.258307200 +1100
@@ -52,6 +52,8 @@
     pidfile=/var/run/${if}.pid
     [ -f $pidfile ] && $DEBUG kill $(cat $pidfile)
 
+    RESOLV_CONF="/tmp/resolv.conf"
+
     case "$1" in
         static)
             ip=$(nvram get ${2}_ipaddr)
@@ -61,10 +63,10 @@
             $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
             ${gateway:+$DEBUG route add default gw $gateway}
     
-            [ -f /etc/resolv.conf ] || {
-                debug "# --- creating /etc/resolv.conf ---"
+            [ -f $RESOLV_CONF ] || {
+                debug "# --- creating $RESOLV_CONF ---"
                 for dns in $(nvram get ${2}_dns); do
-                    echo "nameserver $dns" >> /etc/resolv.conf
+                    echo "nameserver $dns" >> $RESOLV_CONF
                 done
             }
             
diff -ur openwrt/package/dnsmasq/files/S50dnsmasq openwrt-mod/package/dnsmasq/files/S50dnsmasq
--- openwrt/package/dnsmasq/files/S50dnsmasq    2006-01-02 15:27:11.204526400 +1100
+++ openwrt-mod/package/dnsmasq/files/S50dnsmasq    2006-01-02 15:56:01.061939200 +1100
@@ -3,6 +3,8 @@
 . /etc/network.overrides
 [ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
 
+RESOLV_CONF="/tmp/resolv.conf"
+
 # interface to use for DHCP
 iface=lan
 
@@ -25,6 +27,6 @@
   wanproto=$(nvram get wan_proto)
   [ -z "$wanproto" -o "$wanproto" = "none" ] || wanif=$(nvram get wan_ifname)
   
-  args="-l /tmp/dhcp.leases -K -F $(int2ip $start),$(int2ip $end),$(int2ip $netmask),12h ${wanif:+-I ${wanif} }"
+  args="-r $RESOLV_CONF -l /tmp/dhcp.leases -K -F $(int2ip $start),$(int2ip $end),$(int2ip $netmask),12h ${wanif:+-I ${wanif} }"
 }
 dnsmasq ${args}

Attachments (0)

Change History (1)

comment:1 Changed 12 years ago by nbd

  • Resolution set to fixed
  • Status changed from new to closed

added in [2884]

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.