MAC OS X flush DNS cache
Open macOS /Mac OS X terminal application and type the following command under OS X version 10.5 and above:
# dscacheutil -flushcache
Mac OS X Tiger (v10.4) user, enter:
# lookupd -flushcache
macOS 11 Big Sur or 12 Monterey user, try:
# sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS 10.11 El Capitan, 10.12 Sierra, 10.13 High Sierra, 10.14 Mojave, or 10.15 Catalina user try:
# sudo killall -HUP mDNSResponder
On Mac OS X version 10.6 and onwards to dump DNS cached records
$ dscacheutil -cachedump -entries
Display your DNS cached records on Windows
DNS cached records are stored to offload the DNS from querying it all the time in order to resolve the questionable site domain IP.
To view most recent cached DNS records on Windows use cmd:
c:\Windows\> ipconfig /displaydns
Windows IP Configuration
array805.prod.do.dsp.mp.microsoft.com
—————————————-
Record Name . . . . . : array805.prod.do.dsp.mp.microsoft.com
Record Type . . . . . : 1
Time To Live . . . . : 1894
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 52.143.124.236
telemetry-incoming.r53-2.services.mozilla.com
—————————————-
Record Name . . . . . : telemetry-incoming.r53-2.services.mozilla.com
Record Type . . . . . : 1
Time To Live . . . . : 444
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 34.120.208.123
tunnel.googlezip.net
—————————————-
Record Name . . . . . : tunnel.googlezip.net
Record Type . . . . . : 1
Time To Live . . . . : 36756
Data Length . . . . . : 4
…
Use up/down scroll array to see the cached record you need to view in the DNS cache.
Flush DNS Cache on Windows OS
Open the terminal (Start > Run > type cmd and press the [Enter] key) and type the following command to flush DNS on Win XP/2000/7/10 etc:
# ipconfig /flushdns
How to Flush DNS local cache queries on Linux
If you’re using a Linux distro such as Ubuntu, here’s how to flush the DNS cache:
Open the terminal by pressing Ctrl + Alt + T or searching for “Terminal” in the Activities menu.
Run the following command:
If you are running Ubuntu 20.04 LTS Linux or older Linux distro using systemd-resolve, use: sudo systemd-resolve –flush-caches.
If you are running Ubuntu 22.04 LTS or newer, use: sudo resolvectl flush-caches.
Enter your administrator password when prompted, and the DNS cache will be flushed.
To check the change in the DNS record is real, you can check the DNS cache statistics:
# resolvectl statistics
On older Linux distributions where /etc/resolv.conf nameserver directives are used to set the DNS for the server, to flush the cache
only options is to either flush the server used cache or change the nameserver inside the file.
Check the DNS cache records on older Linux distros (requires NSCD daemon)
Assuming the nscd daemon is UP and running (if not you have to install it) to check the cached local DNS records on Linux do
# service nscd status
Reviewing Your DNS Cache on modern Linux distros
The systemd-resolved daemon reacts to USR1 by writing its cache to the system logs. We can then use the journalctl command to filter out the DNS entries.
We'll use the killall command with USR1 To send the signal to the systemd-resolved daemon. Note that although we're using the killall command, the systemd-resolved daemon continues to run. This isn't a termination signal that we're sending.
$ sudo killall -USR1 systemd-resolved
Now we'll use the journalctl command with the -u (filter by systemd unit) option to extract the log entries that have been generated by systemd-resolved . We'll redirect that output into a text files called "dns.txt."
$ sudo journalctl -u systemd-resolved > dns.txt
Then check the DNS records
$ less dns.txt
Then find the cached mappings between domain names and IP addresses in.
How to Flush the dnsmasq Cache on Linux
The dnsmasq application provides a DNS cache and a DHCP server.
dnsmasq is popular among with users who want to run their own DNS server, especially on non-systemd installations.
Flushing the dnsmasq DNS cache is easy. We need to send the SIGHUP signal, which tells the dnsmasq daemon to effectively reinitialize. Doing so clears its DNS cache. To send the signal we use the killall command with the -HUP flag, and the name of the application.
$ sudo killall -HUP dnsmasq
Report haproxy node switch script useful for Zabbix or other monitoring
Tuesday, June 9th, 2020For those who administer corosync clustered haproxy and needs to build monitoring in case if the main configured Haproxy node in the cluster is changed, I've developed a small script to be integrated with zabbix-agent installed to report to a central zabbix server via a zabbix proxy.
The script is very simple it assumed DC1 variable is the default used haproxy node and DC2 and DC3 are 2 backup nodes. The script is made to use crm_mon which is not installed by default on each server by default so if you'll be using it you'll have to install it first, but anyways the script can easily be adapted to use pcs cmd instead.
Below is the bash shell script:
To configure it with zabbix monitoring it can be configured via UserParameterScript.
The way I configured it in Zabbix is as so:
1. Create the userpameter_active_node.conf
Below script is 3 nodes Haproxy cluster
Once pasted to save the file press CTRL + D
The version of the script with 2 nodes slightly improved is like so:
The haproxy_active_DC_zabbix.sh script with a bit of more comments as explanations is available here
2. Configure access for /usr/sbin/crm_mon for zabbix user in sudoers
3. Configure in Zabbix for active.dc key Trigger and Item
Tags: access, ALL, and, Anyways, are, available, awk, bash shell, bash shell script, Below, bit, case, cat, Central, check, Cluster, cmd, Comments, conf, configure
Posted in Linux, Monitoring, Zabbix | No Comments »