[Dnsmasq-discuss] Modification to the feature of config-static DNS record in dual-stack network.

许伟林 mzweilin at gmail.com
Thu Nov 25 11:53:43 GMT 2010


Hi all,
When you add an item 'address=/www.opera.com/2001:840:4073:1::1:101' in
'/etc/dnsmasq.conf', do you mean this site doesn't have an IPv4 address to
access? I wonder it is not true on most occasion, since this kind of sites
can only be accessed by IPv6 host.

However, when you add this item in the config file, dnsmasq-2.55 will reply
an empty record for the DNS query[A] of www.opera.com. And it prints 2 lines
in log file:
*...*
*dnsmasq: query[A] www.opera.com from 192.168.56.101*
*dnsmasq: config www.opera.com is NODATA-IPv4*
*...*

So the pure IPv4 hosts cannot access www.opera.com.

Actually the below feature is what I expected:
*When receiving a DNS query request, dnsmasq firstly looks up the static
record of the same type (A record or AAAA record) in config file. The client
will receive the static DNS record if found. Or the query should be
forwarded to the external DNS server.*

In order to realise this feature, we have to modify some codes in
./src/forward.c.

At the beginning of 'search_servers()', we make a backup of the two
parameters in case they will be modified after a failed query in the config
file. (I'm not sure whether they will be modified.)

*Line 127:  int type_backup = *type;*
*Line 128:  int norebind_backup = *norebind;*

Next we should modify the last 'if-else-if' sentence.
The original codes are :

*  if (flags)*
*    {*
*      int logflags = 0;*
*      *
*      if (flags == F_NXDOMAIN || flags == F_NOERR)*
* **logflags = F_NEG | qtype;*
*  *
*      log_query(logflags | flags | F_CONFIG | F_FORWARD, qdomain, *addrpp,
NULL);*
*    }*
*  else if ((*type) & SERV_USE_RESOLV)*
*    {*
*      *type = 0; /* use normal servers for this domain */*
*      *domain = NULL;*
*    }*
*  return  flags;*

We add an 'if' sentence before 'else'. The modified codes are below:

 * if (flags)*
*    {*
*      int logflags = 0;*
*      *
*      if (flags == F_NXDOMAIN || flags == F_NOERR)*
* **logflags = F_NEG | qtype;*
*  *
*      log_query(logflags | flags | F_CONFIG | F_FORWARD, qdomain, *addrpp,
NULL);*
*      *
*      //A modification to the feature of config-static DNS record.*
*      //Dnsmasq can forward the query that doesn't match the correct type
of a static DNS record.*
*      //By William.Xu(usa911 at bupt.edu.cn)*
*      if (flags == F_NXDOMAIN || flags == F_NOERR){*
* **      flags = 0;*
* **      *type = type_backup;*
* **      *norebind = norebind_backup;*
*      }*
*      *
*
*
*    }*
*  else if ((*type) & SERV_USE_RESOLV)*
*    {*
*      *type = 0; /* use normal servers for this domain */*
*      *domain = NULL;*
*    }*
*  return  flags; *


Now adding an item 'address=/www.google.com/2404:6800:8005::68' in the
config file. The query[A] will be forwarded to the external DNS servers.

*dnsmasq: query[AAAA] www.google.com from 192.168.56.101*
*dnsmasq: config www.google.com is 2404:6800:8005::68*
*dnsmasq: query[A] www.google.com from 192.168.56.101*
*dnsmasq: config www.google.com is NODATA-IPv4*
*dnsmasq: forwarded www.google.com to 211.68.71.4*
*dnsmasq: forwarded www.google.com to 211.68.71.5*
*dnsmasq: reply www.google.com is <CNAME>*
*dnsmasq: reply www-g-com-chn.l.google.com is 74.125.153.104*
*dnsmasq: reply www-g-com-chn.l.google.com is 74.125.153.99*
*
*
*
*
William
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20101125/abe2cd4f/attachment.htm 


More information about the Dnsmasq-discuss mailing list