preface
Use the following command to query DNS in Linux system
dig baidu.com @114.114.114.114
Or use the default DNS server to query
nslookup baidu.com
The following methods may not all work, but you can always find one that works
1.network-manager and networking
In some Linux operating systems, such as the specific version of Ubuntu, DNS is managed by network manager.
In these systems, you need to run the command:
sudo service network-manager restart
In other systems, you can use the following command:
sudo service networking restart
2.ubuntu
In Ubuntu 12.04, you can try the following command:
sudo kill -HUP $(pgrep dnsmasq)
In Ubuntu 16.04 and Debian 9, you can refresh DNS with the following command
sudo systemd-resolve --statistics
On Ubuntu 17.04 and later, use the following command:
sudo systemd-resolve --flush-caches
3 /etc/ resolv.conf
/etc/ resolv.conf This file stores the address of the DNS server. Directly modifying this file can only temporarily change the default DNS address and restore the settings after restart.
You can modify this file directly for temporary use
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
After modification, Ping or NSLOOKUP again will get the IP address from the new DNS server
for the method of permanent modification, see how do I add a DNS server via resolv.conf?
4.nscd
NSCD is a good DNS caching service. Use the following command to install it:
apt install nscd #debian ubuntu
If you have NSCD installed on your Linux system, you can use the following command to refresh DNS:
sudo /etc/init.d/nscd restart
Resources:
How do I clear the DNS cache?
flush DNS cache in Ubuntu
Read More:
- Build LNMPR Error — php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
- Nginx start error: job for nginx.service failed because the control process exited with error code
- MongoDB报错:Failed to start mongod.service: Unit mongod.service is not loaded properly
- Raspberry Pi 3 installation and software configuration issues collection
- Solutions to problems encountered when installing isc-dhcp-server on debian9.6
- PHP link database error PHP_ network_ getaddresses: getaddrinfo failed: Name or service not known
- Ubuntu network configuration+Fixing “Failed to bring up eth0” in Ubuntu
- Microsoft Store install Ubuntu
- Ganglia cannot access: you don’t have permission to access / ganglia on this server
- MongoDB Error: Failed to start mongod.service: Unit mongodb.service is masked
- CentOS uses Yum install to report errors
- Alicloud centos8 reports an error “error: failed to synchronize cache for repo ‘EPEL modular’”
- Vs_ Code remote SFTP connects to the server to modify the nginx configuration information and reports all configured authentication methods failed
- ExecutableNotFound: failed to execute [‘dot’, ‘-Tsvg’], make sure the Graphviz executables are on yo
- CentOS7 nginx Failed to read PID from file /run/nginx.pid: Invalid argument?
- Using xrdp to realize windows remote desktop Ubuntu Linux
- After installation, Ubuntu encountered [SDB] asking for cache data failed assembling drive cache: write through
- Centos7 offline installation of redis and PHP extension redis
- Install And Configure Nagios on Ubuntu 14.04 LTS
- VirtualBox Failed to start LSB:Bring up/down Networking problem