📜  flush dns bash - Shell-Bash (1)

📅  最后修改于: 2023-12-03 15:30:47.823000             🧑  作者: Mango

Flush DNS with Bash Shell

One of the common ways to troubleshoot networking problems is to clear or flush the DNS cache on your computer. In this article, we will explain how to flush DNS using Bash Shell scripts.

Prerequisites

Before proceeding with the steps, ensure that you have the following:

  • A Linux system
  • Bash Shell
Steps to flush DNS using Bash Shell

To flush DNS using Bash Shell, follow the steps below:

  1. Open a terminal window and switch to the root user using the below command:

    sudo su
    
  2. To flush the DNS cache, run the below command:

     systemctl restart network-manager
    

    This command will stop and start the network-manager service, which clears the DNS cache.

    Alternatively, you can use the following command to restart the networking service:

    systemctl restart networking
    
  3. You can also flush the DNS cache by restarting the DNS service using the following command:

    systemctl restart systemd-resolved.service
    

    This command will restart the systemd-resolved service, which clears the DNS cache.

Conclusion

In this tutorial, we have explained how to flush the DNS cache using Bash Shell. Flushing the DNS cache can help resolve networking problems and improve performance.