List all network connection modes
Networksetup-listallnetworkservices
The results are as follows:
sets the DNS server for the specified network connection mode
Networksetup-setdnsservers Wi-Fi 8.8.8.8
Where Wi-Fi refers to your current network name. Not the WiFi name, but the way the network links are listed in the first command, or viewed with a Mac, the name indicated by the following figure arrow.
And 8.8.8.8 is the DNS you want to set up. Check the current DNS settings
Networksetup-getdnsservers Wi-Fi
If you have not set up any DNS, you will be prompted as follows:
empty the current DNS settings
Networksetup-setdnsservers Wi-Fi empty
Emptying the DNS cache
Dscacheutil-flushcache
The server that resolves the corresponding domain name to the IP address is the DNS server. The biggest symptom of DNS resolution failure is that the IP address of the site is not a problem, but accessing his domain name will cause errors. That is, you know that a Web site's IP address can be opened directly in the browser, and you enter its domain name can not be opened. When a computer accesses a domain name, it does not need to seek help from the DNS server for each visit, typically when the resolution is completed once, the resolution entry is saved in the computer's DNS cache list, and if DNS resolution changes, the DNS cache list information is not changed. When the computer accesses the domain name, it still does not connect to the DNS server to obtain the most recent resolution information and resolves it based on the cached correspondence stored on its own computer, which can cause DNS resolution failures