LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Squid 3.1 DNS Timeout Problem (https://www.linuxquestions.org/questions/linux-server-73/squid-3-1-dns-timeout-problem-4175495206/)

stimpack 02-17-2014 05:46 AM

Squid 3.1 DNS Timeout Problem
 
Hi folks,
Every time i try to connect with squid proxy i got this error
Code:

The following error was encountered while trying to retrieve the URL: http://google.com/

    Unable to determine IP address from host name "google.com"

The DNS server returned:

    Refused: The name server refuses to perform the specified operation.

This means that the cache was not able to resolve the hostname presented in the URL. Check if the address is correct.

Your cache administrator is root.

I have checked squid server log and i found this :
Code:

1392635595.842  10003 41.137.74.142 TCP_MISS/404 0 CONNECT aus3.mozilla.org:443 - DIRECT/- -
1392636174.237  10002 41.137.74.142 TCP_MISS/503 4122 GET http://www.facebook.com/ - DIRECT/www.facebook.com text/CODE
1392636185.238  10471 41.137.74.142 TCP_MISS/503 4200 GET http://www.squid-cache.org/Artwork/SN.png - DIRECT/www.squid-cache.org text/CODE
1392636422.617  10003 41.137.74.142 TCP_MISS/503 4374 GET http://google.com/ - DIRECT/google.com text/CODE
1392636433.619  10699 41.137.74.142 TCP_MISS/503 4194 GET http://www.squid-cache.org/Artwork/SN.png - DIRECT/www.squid-cache.org text/CODE
1392636584.839  10004 41.137.74.142 TCP_MISS/503 4410 GET http://google.com/ - DIRECT/google.com text/CODE
1392636595.842  10449 41.137.74.142 TCP_MISS/503 4194 GET http://www.squid-cache.org/Artwork/SN.png - DIRECT/www.squid-cache.org text/CODE

squid.conf
Code:

# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
acl kirmi src 41.0.0.0/8
#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localhost
http_access allow localnet
http_access allow kirmi

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

Any help is appreciated.

Thanks,

Nephew 02-17-2014 06:33 AM

The error message tells you exactly what is wrong. Squid cannot resolve the domain.
By default Squid uses the DNS which is specified in "/etc/resolv.conf"
So check that you can do lookups on the server where squid is running. Like:
Code:

nslookup google.com

stimpack 02-17-2014 06:48 AM

Thanks for the answer but the squid give me this error for all websites not just google..
resolv.conf
domain mediatoolsbox.us
nameserver 127.0.0.1
nameserver 216.120.250.182



Quote:

Originally Posted by Nephew (Post 5119176)
The error message tells you exactly what is wrong. Squid cannot resolve the domain.
By default Squid uses the DNS which is specified in "/etc/resolv.conf"
So check that you can do lookups on the server where squid is running. Like:
Code:

nslookup google.com


Nephew 02-17-2014 06:54 AM

What is the result if you open a terminal and run these 2 commands?
Code:

nslookup google.com 127.0.0.1
nslookup google.com 216.120.250.182


stimpack 02-17-2014 06:58 AM

Server: 216.120.250.182
Address: 216.120.250.182#53

** server can't find google.com: NXDOMAIN
Quote:

Originally Posted by Nephew (Post 5119187)
What is the result if you open a terminal and run these 2 commands?
Code:

nslookup google.com 127.0.0.1
nslookup google.com 216.120.250.182



Nephew 02-17-2014 07:02 AM

Dude, I am gonna stop helping here if you do not answer my questions. I already went out of my way to pre-empt the problem. I asked for the result of the nslookups, but you have not posted it here. This is not a a squid issue but a most likely a DNS issue that you have.

stimpack 02-17-2014 07:14 AM

I have posted the output of nslookup google.com 216.120.250.182
Server: 216.120.250.182
Address: 216.120.250.182#53
** server can't find google.com: NXDOMAIN


and nslookup google.com 127.0.0.1 didnt work.
what should i do about dns issue? thanks

Nephew 02-17-2014 07:22 AM

Sorry missed that. So the DNS specified is not working (216.120.250.182).
Does this machine have full access to the internet? If so then change the resolve.conf file and specify the Google DNS 8.8.8.8 and/or 8.8.4.4.
You can later setup your own DNS if you want, using Bind, for example.

After editing "/etc/resolv.conf" it should look like this:
Code:

domain mediatoolsbox.us
nameserver 8.8.8.8
nameserver 8.8.4.4

Then reload Squid
Code:

squid -k reconfigure
Test again

stimpack 02-17-2014 07:31 AM

Yes Its seems working thanks dude :) . Do u have any guide how to setup my own dns to use it instead of google public DNS.

Nephew 02-17-2014 07:36 AM

Install Bind and sometimes running with the default configs may work. This site is excellent to learn Bind:
http://www.zytrax.com/books/dns/

To test your local DNS, you will run like:
Code:

nslookup google.com 127.0.0.1
If it works, the change the first nameserver entry in resolv.conf to:
Quote:

nameserver 127.0.0.1


All times are GMT -5. The time now is 03:24 AM.