[squid-users] DNS lookup fails initially for FQDN in squid

Amos Jeffries squid3 at treenet.co.nz
Wed Jun 1 11:27:12 UTC 2016


On 1/06/2016 9:05 a.m., Aashima Madaan wrote:
> Hey Amos,
> 
>> What is causing the problem is that ICAP services need to be working
>> *immediately* and do not wait for DNS results to come back. If they are
>> not available immediately then the service is not contactable for that
>> transaction.
> 
>> Adding /etc/hosts entries makes Squid load the name+IP details on
>> startup before ICAP is used. So the problem does not appear.
> Is there a configuration for squid where we can ask it to perform DNS lookup immediately rather than doing later when it sends an OPTIONS request again.
> 

No. DNS lookups are done when they are identified as being needed.

We could perhapse perform a 'seed' lookup while parsing the config.
Though that would be a bit tricky if DNS is differently configured later
in squid.conf than ICAP.

Does the attached patch resolve the issue for you?

Amos

-------------- next part --------------
=== modified file 'src/adaptation/ServiceConfig.cc'
--- src/adaptation/ServiceConfig.cc	2016-01-13 10:10:20 +0000
+++ src/adaptation/ServiceConfig.cc	2016-06-01 11:20:31 +0000
@@ -14,6 +14,8 @@
 #include "Debug.h"
 #include "globals.h"
 #include "ip/tools.h"
+#include "ipcache.h"
+
 #include <set>
 
 Adaptation::ServiceConfig::ServiceConfig():
@@ -234,6 +236,7 @@
     }
 
     host.limitInit(s, len);
+    (void)ipcache_gethostbyname(host.termedBuf(), IP_LOOKUP_IF_MISS);
 #if USE_OPENSSL
     if (secure.sslDomain.isEmpty())
         secure.sslDomain.assign(host.rawBuf(), host.size());



More information about the squid-users mailing list