<div>Hi all,</div><div>When you add an item 'address=/<a href="http://www.opera.com/2001:840:4073:1::1:101">www.opera.com/2001:840:4073:1::1:101</a>' 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.</div>
<div><br></div><div>However, when you add this item in the config file, dnsmasq-2.55 will reply an empty record for the DNS query[A] of <a href="http://www.opera.com">www.opera.com</a>. And it prints 2 lines in log file:</div>
<div><i>...</i></div><div><i>dnsmasq: query[A] <a href="http://www.opera.com">www.opera.com</a> from 192.168.56.101</i></div><div><i>dnsmasq: config <a href="http://www.opera.com">www.opera.com</a> is NODATA-IPv4</i></div>
<div><i>...</i></div><div><br></div><div>So the pure IPv4 hosts cannot access <a href="http://www.opera.com">www.opera.com</a>.</div><div><br></div><div>Actually the below feature is what I expected:</div><div><b>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.</b></div>
<div><br></div><div>In order to realise this feature, we have to modify some codes in ./src/forward.c.</div><div><br></div><div>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.)</div>
<div><br></div><div><i>Line 127: int type_backup = *type;</i></div><div><i>Line 128: int norebind_backup = *norebind;</i></div><div><br></div><div>Next we should modify the last 'if-else-if' sentence.</div><div>
The original codes are :</div><div><br></div><div><i> if (flags)</i></div><div><i> {</i></div><div><i> int logflags = 0;</i></div><div><i> </i></div><div><i> if (flags == F_NXDOMAIN || flags == F_NOERR)</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>        </i></span><i>logflags = F_NEG | qtype;</i></div><div><i> </i></div><div><i> log_query(logflags | flags | F_CONFIG | F_FORWARD, qdomain, *addrpp, NULL);</i></div>
<div><i> }</i></div><div><i> else if ((*type) & SERV_USE_RESOLV)</i></div><div><i> {</i></div><div><i> *type = 0; /* use normal servers for this domain */</i></div><div><i> *domain = NULL;</i></div><div>
<i> }</i></div><div><i> return flags;</i></div><div><br></div><div>We add an 'if' sentence before 'else'. The modified codes are below:</div><div><br></div><div> <i> if (flags)</i></div><div><i> {</i></div>
<div><i> int logflags = 0;</i></div><div><i> </i></div><div><i> if (flags == F_NXDOMAIN || flags == F_NOERR)</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>        </i></span><i>logflags = F_NEG | qtype;</i></div>
<div><i> </i></div><div><i> log_query(logflags | flags | F_CONFIG | F_FORWARD, qdomain, *addrpp, NULL);</i></div><div><i> </i></div><div><i> //A modification to the feature of config-static DNS record.</i></div>
<div><i> //Dnsmasq can forward the query that doesn't match the correct type of a static DNS record.</i></div><div><i> //By William.Xu(<a href="mailto:usa911@bupt.edu.cn">usa911@bupt.edu.cn</a>)</i></div><div>
<i> if (flags == F_NXDOMAIN || flags == F_NOERR){</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>        </i></span><i> flags = 0;</i></div><div><span class="Apple-tab-span" style="white-space:pre"><i>        </i></span><i> *type = type_backup;</i></div>
<div><span class="Apple-tab-span" style="white-space:pre"><i>        </i></span><i> *norebind = norebind_backup;</i></div><div><i> }</i></div><div><i> </i></div><div><i><br></i></div><div><i> }</i></div><div><i> else if ((*type) & SERV_USE_RESOLV)</i></div>
<div><i> {</i></div><div><i> *type = 0; /* use normal servers for this domain */</i></div><div><i> *domain = NULL;</i></div><div><i> }</i></div><div><i> return flags; </i></div><div><br></div><div><br></div>
<div>Now adding an item 'address=/<a href="http://www.google.com/2404:6800:8005::68">www.google.com/2404:6800:8005::68</a>' in the config file. The query[A] will be forwarded to the external DNS servers.</div><div>
<br></div><div><i>dnsmasq: query[AAAA] <a href="http://www.google.com">www.google.com</a> from 192.168.56.101</i></div><div><i>dnsmasq: config <a href="http://www.google.com">www.google.com</a> is 2404:6800:8005::68</i></div>
<div><i>dnsmasq: query[A] <a href="http://www.google.com">www.google.com</a> from 192.168.56.101</i></div><div><i>dnsmasq: config <a href="http://www.google.com">www.google.com</a> is NODATA-IPv4</i></div><div><i>dnsmasq: forwarded <a href="http://www.google.com">www.google.com</a> to 211.68.71.4</i></div>
<div><i>dnsmasq: forwarded <a href="http://www.google.com">www.google.com</a> to 211.68.71.5</i></div><div><i>dnsmasq: reply <a href="http://www.google.com">www.google.com</a> is <CNAME></i></div><div><i>dnsmasq: reply <a href="http://www-g-com-chn.l.google.com">www-g-com-chn.l.google.com</a> is 74.125.153.104</i></div>
<div><i>dnsmasq: reply <a href="http://www-g-com-chn.l.google.com">www-g-com-chn.l.google.com</a> is 74.125.153.99</i></div><div><i><br></i></div><div><i><br></i></div><div>William</div>