[Dnsmasq-discuss] standard gateway as Forwarding DNS-ip?

richardvoigt at gmail.com richardvoigt at gmail.com
Fri May 18 23:56:39 BST 2012


On Fri, May 18, 2012 at 7:09 AM, Oliver Rath <rath at mglug.de> wrote:
> Hi list,
>
> my dnsmasq doesnt forward DNS-queries correctly. The goal is, that
> dnsmasq takes the standard-gateway of dhcp as forwarding address for
> dns-requests. But this didnt work here.



In such a case, you configure your DHCP client to not put the
negotiated DNS server into /etc/resolv.conf, but into an alternate
file.  And configure dnsmasq to use it.  From your configuration it
sounds as if you are using  /var/run/dnsmasq/resolv.conf, I guess that
is specified in your startup scripts on the command line, instead of
in the configuration file?  So far so good.

But it sounds as if you haven't told the DHCP client about that file.
For dhclient, you need to modify the dhclient-script.  udhcpc also
supports a script file.  With dhcpcd, the situation is more
problematic.  You can only choose to overwrite /etc/resolv.conf or
not.  Luckily you can use a resolv.conf.head to make sure your dnsmasq
address (localhost 127.0.0.1) stays on top, and dhcpcd will add the
negotiated entry beneath it.  dnsmasq is smart enough to skip the
localhost entry and use the other, but you'd need to defeat the
configuration option looking in /var/run/dnsmasq, and instead monitor
/etc/resolv.conf (the default).

BTW, it's not dnsmasq overwriting /etc/resolv.conf



>
> If I put an additional dns-server in /var/run/dnsmasq/resolv.conf, it
> runs fine, but this is not the right way, because i dont know at
> starttime the name of my standard-gateway.
>
> Whats wrong?
>
> I have a simple configuration here for dnsmasq:
> --------------
> except-interface=wlan0
> dhcp-range=192.168.97.50,192.168.97.150,255.255.255.0,12h
> log-queries
> --------------
>
> Starting the dnsmasq creates the folloiwing entry in /etc/resolv.conf:
> --------------
> # Dynamic resolv.conf(5) file for glibc resolver(3) generated by
> resolvconf(8)
> # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
> nameserver 127.0.0.1
> --------------
>
> The server hast the ipadress 192.168.11.254 (eth0) and (should) forward
> to 192.168.172.1 via wlan0
>
> --------------
> # route -n
> Kernel-IP-Routentabelle
> Ziel Router Genmask Flags Metric Ref Use Iface
> 0.0.0.0 192.168.172.1 0.0.0.0 UG 0 0 0 wlan0
> 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 wlan0
> 192.168.97.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
> 192.168.172.0 0.0.0.0 255.255.255.0 U 2 0 0 wlan0
> --------------
>
> Now the forwarding is finished by setting forwarding parameter and
> Masquerading rule:
> --------------
> # cat /proc/sys/net/ipv4/ip_forward
> 1
> # iptables -t nat -L
> [..]
> Chain POSTROUTING (policy ACCEPT)
> target prot opt source destination
> MASQUERADE all -- anywhere anywhere
> --------------
>
>
> Here the starting log:
> --------------
> May 18 13:58:14 dnsmasq[3092]: last message repeated 7 times
> May 18 13:58:14 dmi-ThinkPad-T500 dnsmasq[3092]: reading
> /var/run/dnsmasq/resolv.conf
> May 18 13:58:14 dmi-ThinkPad-T500 dnsmasq[3092]: ignoring nameserver
> 127.0.0.1 - local interface
> May 18 13:58:14 dmi-ThinkPad-T500 dnsmasq[3092]: exiting on receipt of
> SIGTERM
> May 18 13:58:16 dmi-ThinkPad-T500 dnsmasq[3182]: started, version 2.59
> cachesize 150
> May 18 13:58:16 dmi-ThinkPad-T500 dnsmasq[3182]: compile time options:
> IPv6 GNU-getopt DBus i18n DHCP TFTP conntrack IDN
> May 18 13:58:16 dmi-ThinkPad-T500 dnsmasq-dhcp[3182]: DHCP, IP range
> 192.168.97.50 -- 192.168.97.150, lease time 12h
> May 18 13:58:16 dmi-ThinkPad-T500 dnsmasq-tftp[3182]: TFTP root is
> /opt/dmi/tftproot
> May 18 13:58:16 dmi-ThinkPad-T500 dnsmasq[3182]: reading
> /var/run/dnsmasq/resolv.conf
> May 18 13:58:16 dmi-ThinkPad-T500 dnsmasq[3182]: ignoring nameserver
> 127.0.0.1 - local interface
> May 18 13:58:16 dmi-ThinkPad-T500 dnsmasq[3182]: /etc/hosts lesen – 7
> Adressen
> --------------
>
>
> here an dns-request example:
> --------------
> May 18 13:59:00 dmi-ThinkPad-T500 dnsmasq[3182]: reading
> /var/run/dnsmasq/resolv.conf
> May 18 13:59:00 dmi-ThinkPad-T500 dnsmasq[3182]: ignoring nameserver
> 127.0.0.1 - local interface
> May 18 13:59:00 dmi-ThinkPad-T500 dnsmasq[3182]: query[A] heise.de from
> 192.168.97.73
> --------------
>
>
> Tfh!
>
> Regards
> Oliver
>
>
>
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss



More information about the Dnsmasq-discuss mailing list