Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I work on Linux on my laptop, I could not access a particular website using the URL, so I used sudo /etc/init.d/nscd restart in order to clear the DNS cache, but the URL is still throws 'Server Not Found' in Firefox. I have tried also Chrome, it still not working. Other friends can see the web page, but I can not. So what would be the main cause of this? I can surf other sites nicely.

Weirdly enough when I even try the IP address of that particular URL, it shows me a different page than what other people see.

I appreciate any help on this matter.

share|improve this question
1  
Does host www.strangesite.co.uk return the IP you expect? (Showing different content when you go there via the IP is not unusual, it's called name-based virtual hosting.) –  Ulrich Schwarz Mar 21 '12 at 12:32
    
@UlrichSchwarz the IP has a default page coming from cgi-sys/defaultwebpage.cgi, but when I use the main URL, no browser in my laptop shows anything except throwing errors that they couldn't connect to the server. –  mika Mar 21 '12 at 12:39
    
Have you checked your /etc/hosts file to make sure you aren't redirecting the hostname or IP address? –  FloppyDisk Mar 21 '12 at 12:52
    
checked the file and here is what it has:'127.0.0.1 localhost 127.0.1.1 ---name-VGN-model-N # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters' –  mika Mar 21 '12 at 12:58
    
Ping the website from the working machine, what IP do you get? Ping the website from the laptop, is it the same IP? Does it resolve? What happens if you take DNS out of the equation? Try pinging the IP from the working machine directly on the laptop. What happens? If you get a response on the IP only on the laptop try entering that into the browser address bar. What happens? –  2bc Mar 21 '12 at 13:57

2 Answers 2

up vote 4 down vote accepted

Unless you are running bind by accident you should check your nscd configuration file located at /etc/nscd.conf.

It will list the caches that are kept.

 enable-cache            hosts           yes
 positive-time-to-live   hosts           3600
 .......

# nscd -?

-g, --statistics Print current configuration statistics

-i, --invalidate=TABLE Invalidate the specified cache

nscd -g

    hosts cache:

        yes  cache is enabled
         no  cache is persistent
        yes  cache is shared
        211  suggested size
     216064  total data pool size
        384  used data pool size
        600  seconds time to live for positive entries
          0  seconds time to live for negative entries
          0  cache hits on positive entries
          0  cache hits on negative entries
        128  cache misses on positive entries
          0  cache misses on negative entries
          0% cache hit rate
          3  current number of cached values
          7  maximum number of cached values
          2  maximum chain length searched
          0  number of delays on rdlock
          0  number of delays on wrlock
          0  memory allocations failed
        yes  check /etc/{hosts,resolv.conf} for changes

# nscd -i hosts

This will invalidate the cache.

But, after doing it there was no change to the hosts entries in nscd -g After restarting nscd it was flushed.

service nscd restart

    hosts cache:

        yes  cache is enabled
         no  cache is persistent
        yes  cache is shared
        211  suggested size
     216064  total data pool size
          0  used data pool size
        600  seconds time to live for positive entries
          0  seconds time to live for negative entries
          0  cache hits on positive entries
          0  cache hits on negative entries
          0  cache misses on positive entries
          0  cache misses on negative entries
          0% cache hit rate
          0  current number of cached values
          0  maximum number of cached values
          0  maximum chain length searched
          0  number of delays on rdlock
          0  number of delays on wrlock
          0  memory allocations failed
        yes  check /etc/{hosts,resolv.conf} for changes

Unless you are running bind this is the only way to clear the cache short of finding the database for nscd and deleting it which could cause other issues. I would follow the troubleshooting procedures for IP resolution. I outlined some in the comments to your question.

This is a link to a pretty good Linux Journal article on Troubleshooting Network Problems.

share|improve this answer
    
This is great. Thank you, it worked like a charm now. Now I can comfortably visit my site. Nice help. –  mika Mar 21 '12 at 15:05

I know its an old question, but adding this in case someone is facing this issue again.

When I faced a similar DNS client cache issue this morning, I did all the regular steps to clear the cache stored by nscd and as mentioned in the first answer, restarted nscd. I even dropped the OS cache, but a certain hostname was still resolving to the old IP address. It started resolving only after I removed the nameserver 127.0.0.1 line from resolv.conf.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.