[BATCH] Change DNS Server

Discussion in 'Scripting' started by CODYQX4, Aug 31, 2011.

  1. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,857
    150
    #1 CODYQX4, Aug 31, 2011
    Last edited by a moderator: Apr 20, 2017
    Based on an article I read, using OpenDNS or Google is faster than ISP DNS, because they are working with CDNs to make sure you use the nearest server. The result is faster YouTube videos and stuff that.

    So I made 3 batch files, one for AutoDNS (default/dhcp), one for Google DNS, and one for OpenDNS.

    They change the "Local Area Connection", "Wireless Network Connection", and "Connectify". The first two are default names for your LAN Card and Wireless card, and the "Connectify is "Wireless Network Connection 2" renamed, which my PC used for Connectify.

    The code is simple to extend for more adapters/different names.

    Google
    Code:
    netsh interface ip set dns "Local Area Connection" static 8.8.8.8
    netsh interface ip add dns name="Local Area Connection" addr=8.8.4.4
    netsh interface ip set dns "Connectify" static 8.8.8.8
    netsh interface ip add dns name="Connectify" addr=8.8.4.4
    netsh interface ip set dns "Wireless Network Connection" static 8.8.8.8
    netsh interface ip add dns name="Wireless Network Connection" addr=8.8.4.4
    pause
    OpenDNS
    Code:
    netsh interface ip set dns "Local Area Connection" static 208.67.222.222
    netsh interface ip add dns name="Local Area Connection" addr=208.67.220.220
    netsh interface ip set dns "Connectify" static 208.67.222.222
    netsh interface ip add dns name="Connectify" addr=208.67.220.220
    netsh interface ip set dns "Wireless Network Connection" static 208.67.222.222
    netsh interface ip add dns name="Wireless Network Connection" addr=208.67.220.220
    pause
    Normal DNS
    Code:
    netsh interface ip set dns "Local Area Connection" dhcp
    netsh interface ip set dns "Connectify" dhcp
    netsh interface ip set dns "Wireless Network Connection" dhcp
    pause
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    If you use a router, it would be far more productive to set the DNS information within its configuration and leave all PCs on your network alone.
     
  3. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,857
    150
    Yeah, but some of us only have one PC or are stuck on a college network where we can't touch the router. This has its uses and shows how to change this kind of thing via cmd.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    103
    10
    Well to be fair only a minority of people here would be in that situation, which is why I mentioned it.

    Also in order for the script to be of real value, I would suggest that it only changes one network connections settings and is capable of programatically determining which one of those connections to change. (instead of asking each person to find out the name of the correct connection and inputting it by hand into the script before running it).
     
  5. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,857
    150
    It's just something quick I whipped up, but if someone wants to change it like that it would be nice.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. PalermoTech46

    PalermoTech46 MDL Junior Member

    Nov 18, 2011
    61
    2
    0
    Very good work here. Saving minutes worldwide! time the greatest asset.
     
  7. sebus

    sebus MDL Guru

    Jul 23, 2008
    5,784
    1,732
    180
    Sure, let Google take over your life completly, now they do not have to track your queries in search engine, they have you using their DNS - like telling the whole street all you darkest secrets & hoping it will be OK

    sebus
     
  8. CODYQX4

    CODYQX4 MDL Developer

    Sep 4, 2009
    4,801
    44,857
    150
    I'm not personally using their DNS, but I'm sure I sold myself to Google when I decided to use Chrome anyway, god only knows what they get out of it.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. meiskam

    meiskam MDL Novice

    Jul 17, 2012
    1
    0
    0
    thanks CODYQX4, I hated how connectify forced me to use opendns and not the dns setting I had on the router.
     
  10. wr1334

    wr1334 MDL Novice

    Mar 23, 2013
    3
    0
    0
    When I run this batch file am getting as The filename, directory name or volume label syntax is incorrect. What to do?

    Thanks in Advance.
     
  11. _patrik_

    _patrik_ MDL Member

    May 25, 2007
    175
    43
    10
  12. wtarkan

    wtarkan MDL Member

    Sep 1, 2009
    137
    181
    10
    and now Dns Jumper v1.0.5 has IPv6 support , thanks
     
  13. Roscon

    Roscon MDL Novice

    Jul 15, 2017
    17
    11
    0
    Free and Public DNS Servers:
    Updated list of the best publicly available and completely free DNS servers
    lifewire. com/free-and-public-dns-servers-2626062

    Preferably in my case I prefer the "Provider "Yandex. DNS" and preferably "Yandex Family" which is perhaps one of the fastest and safest.
    DNS.Yandex
    ---------------------------------
    ** For Connection with IPv4:
    ---------------------------------

    Yandex's Basic:

    Primary DNS Server : 77.88.8.8
    Secondary DNS Server : 77.88.8.1

    Yandex's Safe:

    Primary DNS Server : 77.88.8.8
    Secondary DNS Server : 77.88.8.2

    Yandex's Family:

    Primary DNS Server : 77.88.8.8
    Secondary DNS Server : 77.88.8.3

    ---------------------------------
    ** For Connection with IPv6:
    ---------------------------------

    Yandex's Basic:

    Primary DNS Server : 2a02:6b8::feed:0ff
    Secondary DNS Server : 2a02:6b8:0:1::feed:0ff

    Yandex's Safe:

    Primary DNS Server : 2a02:6b8::feed:bad
    Secondary DNS Server : 2a02:6b8:0:1::feed:bad

    Yandex's Family:

    Primary DNS Server : 2a02:6b8::feed:a11
    Secondary DNS Server : 2a02:6b8:0:1::feed:a11
     
  14. TairikuOkami

    TairikuOkami MDL Addicted

    Mar 15, 2014
    539
    342
    30
    To change DNS for any DHCP connection (no need to know the name):
    Code:
    wmic nicconfig where DHCPEnabled=TRUE call SetDNSServerSearchOrder ("208.67.222.222","208.67.220.220")
    To change DNS based on MAC address:
    Code:
    wmic nicconfig where macaddress="D0:17:C2:D0:30:DC" call SetDNSServerSearchOrder ("84.200.70.40","84.200.69.80")