How to make changes to DNS configuration take effect immediately in Linux?
In Linux systems, changes to DNS configurations don’t take effect immediately, instead requiring a restart of the network service or a refresh of the DNS cache for the changes to be applied.
Here are two ways that can take immediate effect:
- Restart network services.
- If you are using systemd, you can restart the network service with the following command: sudo systemctl restart network.
- If you are using init.d, you can restart the network service with the following command: sudo /etc/init.d/network restart.
- Clearing the DNS cache:
- If you are using systemd-resolved, you can refresh the DNS cache by using the following command: sudo systemd-resolve –flush-caches
- If you are using nscd (Name Service Cache Daemon), you can refresh the DNS cache with the following command: sudo /etc/init.d/nscd restart.
- If you are using dnsmasq, you can refresh the DNS cache with the following command: sudo /etc/init.d/dnsmasq restart.
You can immediately make DNS configurations take effect by using any of the methods mentioned above.