Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to clear DNS cache in Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to clear DNS cache in Linux", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "How to clear DNS cache in Linux"!

DNS cache: DNS cache refers to DNS returned the correct IP, the system will temporarily store this result. And it will set an expiration time for the cache (for example, N hours), within which N hours, when you visit the site again, the system will return the results directly from your computer's local DNS cache to you, without having to ask the DNS server, disguised as "accelerated" URL resolution. Of course, after more than N hours, the system will automatically query the DNS server again for new results. So, when you modify the DNS server and do not want the computer to continue to use the previous DNS cache, you need to manually clear the local cache.

Local DNS delays or local dns anomalies will cause access to some websites to be inaccessible. At this time, we need to manually clear the local dns cache instead of waiting!

Linux DNS cache specific method: Nscd will cache libc-initiated name service requests. If retrieving NSS data is considered slow, nscd can significantly speed up sequential access to the same data and improve overall system performance. Just restart nscd to refresh cache:

/etc/init.d/nscd restart

# service nscd restart or

# service nscd reload This daemon provides a cache for the most common name service requests. The default configuration file,/etc/nscd.conf, determines the behavior of the cache daemon.

Clear dnsmasq dns cache

DNSMASQ is a lightweight DNS, TFTP and DHCP server. Its purpose is to provide paired DNS and DHCP services for a local area network. dnsmasq accepts DNS queries and replies to them from a small local cache or forwards them to a true recursive DNS server. The software is also installed on many inexpensive routers to cache DNS queries. Simply restart dnsmasq's service to clear the DNS cache:

$ sudo /etc/init.d/dnsmasq restart

# service dnsmasq restart Clear the DNS cache of the BIND cache server

A BIND cache server obtains information from another server (the regional master) in response to a host query and stores (caches) the data locally. All you have to do is restart BIND to clear its cache:

# /etc/init.d/named restart You can also use the following rndc command to clear all caches:

# rndc restart or

# rndc execBIND v9.3.0 and above supports a command to clear all records cache for a specific domain name: rndc flushname. In this example, refresh all records in the cyberciti.biz domain:

# rndc flushname cyberciti.biz also clears BIND View. For example, LAN and WAN views can be cleared with the following command:

# rndc flush lan # rndc flush wan Tips for Mac OS X Unix users

On Mac, enter the following command as root:

# dscacheutil -flushcache or

$ sudo dscacheutil -flushcache If you are using OS X 10.5 or earlier, try the following command:

LOOKUPD -Flushcache A hint about the/etc/hosts file

/etc/hosts is used as a table to statically query hosts. You need to remove and/or update it on Unix-like operating systems as you wish:

# vi /etc/hosts Sample output:

127.0.0.1 localhost 127.0.1.1 wks01.WAG160N wks01 # 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 10.37.34.2 build 192.168.1.10 nas01 192.168.1.11 nas02 192.168.1.12 nas03 #192.168.2.50 nfs2.nixcraft.net.in nfs2 #192.168.2.51 nfs1.nixcraft.net.in nfs1 172.168.232.50 nfs1.nixcraft.net.in nfs1 172.168.232.51 nfs2.nixcraft.net.in nfs2 192.168.1.101 vm01 At this point, I believe that everyone has a deeper understanding of "how to clear DNS cache in Linux", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report