Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CMCDragonkai/c00969eac6ee8fbb260ceb878128dde5 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/c00969eac6ee8fbb260ceb878128dde5 to your computer and use it in GitHub Desktop.
Reload the DNS Cache in Network Manager

Reload the DNS Cache in Network Manager

You may be using NetworkManager with dnsmasq as the DNS plugin. If so, it's being used as a local caching nameserver.

When its data is outdated, you can force it to reload its DNS cache with:

Use:

nmcli general reload dns-full

You can also use:

nmcli general reload

Which will reload all network manager configuration.

@CMCDragonkai
Copy link
Author

CMCDragonkai commented Jun 19, 2022

Note that this only reloads your local nameserver. The dnsmasq may be configured to contact external nameservers, including the nameservers provided by DHCP, and these nameservers may have their own caching. In those cases you have to wait for the external nameserver to expire their own entries, or if you control them, you can attempt to refresh those caches.

In the case of DHCP, it's most likely that your router maintains its own DNS cache. If so, refresh that.

It is recommended though at least for laptops to never rely on router DNS. Always configure your machine to use the DNS servers like 1.1.1.1 and 8.8.8.8, and should bypass any dodgy router DNS. Only use router DNS if you are setting up some home network.

@gombossb
Copy link

gombossb commented Nov 8, 2022

Thanks, finally a guide that works and does what its title says

@szpeter80
Copy link

On Ubuntu 22.04.1 the reload works but dns cache is not cleared.

For older Ubuntus sudo systemd-resolve --flush-caches might work, on 22.04 one may use sudo resolvectl flush-caches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment