Clear DNS query cache on Linux/Unix/Mac
Introduction | Under MS-Windows, you can use the ipconfig command to clear the dns cache. However, Linux and Unix provide different methods to clear cache. Linux can run nscd or BIND or dnsmasq as the name service cache daemon. Large or workgroup servers may use BIND or dnsmasq as a dedicated cache server to speed up queries. |
Nscd will cache name service requests initiated by libc. If retrieving NSS data is considered slow, nscd can significantly speed up consecutive accesses to the same data and improve the performance of the entire system. Just restart nscd to flush the cache:
$ sudo /etc/init.d/nscd restart
or
# service nscd restart
or
# service nscd reload
This daemon provides a cache for the most commonly used name service requests. The default configuration file /etc/nscd.conf, which determines the behavior of the cache daemon.
Clear dnsmasq dns cachednsmasq is a lightweight DNS, TFTP and DHCP server. Its purpose is to provide paired DNS and DHCP services to the local area network. dnsmasq accepts DNS queries and answers them from a small local cache or forwards them to a real recursive DNS server. This software is also installed on many cheap routers to cache DNS queries. Just restart the dnsmasq service to clear the DNS cache:
$ sudo /etc/init.d/dnsmasq restart
or
# service dnsmasq restartClear the dns cache of the BIND cache server
A BIND cache server obtains information from another server (region master) in response to the host's query, and then saves (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 exec
BIND v9.3.0 and above support a command to clear the cache of all records for a specific domain name: rndc flushname. In this example, refresh all records of cyberciti.biz related domains:
# rndc flushname cyberciti.biz
BIND View can also be cleared. For example, LAN and WAN Views can be cleared with the following command:
# rndc flush lan # rndc flush wanTips for Mac OS X Unix users
Enter the following command as root user on Mac:
# dscacheutil -flushcache
or
$ sudo dscacheutil -flushcache
If you are using OSX 10.5 or earlier, try using the following command:
lookupd -flushcache
A tip about the /etc/hosts file
/etc/hosts is used as a table to statically query hosts. You need to remove and/or update it according to your requirements under a Unix-like operating system:
# vi /etc/hosts
Example 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
The above is the detailed content of Clear DNS query cache on Linux/Unix/Mac. For more information, please follow other related articles on the PHP Chinese website!

The main difference between Linux and Windows in process management lies in the implementation and concept of tools and APIs. Linux is known for its flexibility and power, relying on kernel and command line tools; while Windows is known for its user-friendliness and integration, mainly managing processes through graphical interfaces and system services.

Linuxisidealforcustomization,development,andservermanagement,whileWindowsexcelsineaseofuse,softwarecompatibility,andgaming.Linuxoffershighconfigurabilityfordevelopersandserversetups,whereasWindowsprovidesauser-friendlyinterfaceandbroadsoftwaresupport

The main difference between Linux and Windows in user account management is the permission model and management tools. Linux uses Unix-based permissions models and command-line tools (such as useradd, usermod, userdel), while Windows uses its own security model and graphical user interface (GUI) management tools.

Linux'scommandlinecanbemoresecurethanWindowsifmanagedcorrectly,butrequiresmoreuserknowledge.1)Linux'sopen-sourcenatureallowsforquicksecurityupdates.2)Misconfigurationcanleadtovulnerabilities.Windows'commandlineismorecontrolledbutlesscustomizable,with

This guide explains how to automatically mount a USB drive on boot in Linux, saving you time and effort. Step 1: Identify Your USB Drive Use the lsblk command to list all block devices. Your USB drive will likely be labeled /dev/sdb1, /dev/sdc1, etc

Cross-platform applications have revolutionized software development, enabling seamless functionality across operating systems like Linux, Windows, and macOS. This eliminates the need to switch apps based on your device, offering consistent experien

Artificial Intelligence (AI) is rapidly transforming numerous sectors, from healthcare and finance to creative fields like art and music. Linux, with its open-source nature, adaptability, and performance capabilities, has emerged as a premier platfo

Looking for a fast, minimal, and efficient Linux distribution without a graphical user interface (GUI)? Lightweight, GUI-less Linux distros are perfect for older hardware or specialized tasks like servers and embedded systems. They consume fewer res


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
