Linux – DNS issue with squid

linuxPROXYsquid

I'm having DNS issues with a squid setup. I also tried using dns_nameservers directive in my squid.conf to point to the DNS servers. I have a scenario where www.example.com is supposed to go out to the internet, but foo.example.com is supposed to go to an internal domain. From my client, when I attempt to ping foo.example.com, it picks up the right IP, but I get this error on my browser:

Unable to determine IP address from hostname foo.example.com  
The DNS server returned:  
Name Error: The domain name does not exist

I know that my client is pointing to right IP (because ping works fine), but I'm curious why squid would attempt to connect to the public example.com.

Best Answer

Documentation I read suggest that by default, Squid picks up the name servers from the file /etc/resolv.conf. However, that didn't work for me. Although the OS (Debian) itself could resolve the IP, squid was complaining. I made the following changes and got it working:
/etc/nsswitch.conf:
hosts: files dns
/etc/hosts:
<ip_of_server> foo.example.com

I'm still trying to figure out why squid doesn't pick up name servers from /etc/resolv.conf.

Related Topic