Introduction

Changing DNS settings can improve network performance and reliability. Using command line tools like netsh and ipconfig, you can easily configure DNS servers and refresh the DNS resolver cache. This method is particularly useful for automation and remote management.

Setting Primary DNS Server

To set the primary DNS server, use the following command:

netsh interface ip set dns "Connexion au r‚seau local" static 8.8.8.8 primary

This command sets the primary DNS server for the network interface named “Connexion au réseau local” to Google’s public DNS server (8.8.8.8).

Adding Secondary DNS Server

To add a secondary DNS server, use the following command:

netsh interface ip add dns "Connexion au r‚seau local" 192.168.1.1 index=2

This command adds a secondary DNS server (192.168.1.1) with an index of 2 to the same network interface.

Flushing DNS Cache

After changing DNS settings, it is a good practice to flush the DNS cache to ensure that the new settings take effect immediately. Use the following command:

ipconfig /flushdns

This command clears the DNS resolver cache, forcing the system to use the new DNS settings.

Example Script

Here is a complete script to set primary and secondary DNS servers and flush the DNS cache:

@echo off
REM Set primary DNS server
netsh interface ip set dns "Connexion au r‚seau local" static 8.8.8.8 primary

REM Add secondary DNS server
netsh interface ip add dns "Connexion au r‚seau local" 192.168.1.1 index=2

REM Flush DNS cache
ipconfig /flushdns

REM Output completion message
echo DNS settings updated and cache flushed.
pause


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.