Jump to content
TorGuard
  • 0
AusFlyGuy

How To Dynamically Change DNS Servers from Google/OpenDNS (With Viscosity)

Rate this question

Question

AusFlyGuy

Hi everyone,

Included in this post is a Windows Batch file to dynamically change the DNS Servers of ANY successful connection to something other than the Google public servers provided by TorGuard through DHCP.

This is needed to ensure use of a non-logging DNS Service.

 

Your feedback would be appreciated :)

 

The full file can be downloaded here -- TorGuard_ChgDNS.bat

Instructions are included.

 

Extract from the file-

 

:: Author: Ian McOwan, Broadford, Australia

:: Date: 31st August 2014

::

:: Setable Parameters:

:: adapterName - The name on the Windows Network Connection created by TorGuard

:: priDNSserver - The preferred primary DNS Server [TorGuard Free Secure DNS]

:: secDNSserver - The preferred secondary DNS Server [TorGuard Free Secure DNS]

:: onlyChangeFromGoogle - Only changes successful connections that are using Google DNS Servers [default Y]

:: googlePriServer - 8.8.8.8, server to search for [default]

::

  • Like 1

Share this post


Link to post
Share on other sites

16 answers to this question

Recommended Posts

  • 0
Support

This looks handy, thanks for the contribution.

Share this post


Link to post
Share on other sites
  • 0
59696_1511348127

Ian I am brand-spanking-new to TorGuard but was alarmed that the dnsleaktest.com said Google was still involved with DN resolution. So I tried your .bat and it does seem to work, thank you! I'm trying to rid my online world of Google and it seems very hard to do because they are everywhere!

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
AusFlyGuy

Hi TorWorx.

thank you for your feedback it is appreciated.

 

Would you tell me the O/S you're running?

 

Regards Ian

Share this post


Link to post
Share on other sites
  • 0
59696_1511348127

Yes this PC is running Windows 7 Home Premium 64-bit version w/SP1 & all latest...

Share this post


Link to post
Share on other sites
  • 0
Guest
Ian I am brand-spanking-new to TorGuard but was alarmed that the dnsleaktest.com said Google was still involved with DN resolution. So I tried your .bat and it does seem to work, thank you! I'm trying to rid my online world of Google and it seems very hard to do because they are everywhere!

 

Try to run the command prompt (cmd) as Admin (rightclick -> run as admin)

Then navigate to the batch file (i.e. cd c:temp)

Now run the batch file (TorGuard_ChgDNS.bat)

 

When I run the batch file by itself (even with run as admin) it won't work for me either.

Share this post


Link to post
Share on other sites
  • 0
AusFlyGuy

Hi,

 

can you open a command prompt and type in the following command -

 

ipconfig /all > c:ipconfig.txt

 

This will place the output of an ipconfig command into a file in the root directory. Then send the output to

 

[email protected]

 

I'll then fix the code for you and repost :)

Share this post


Link to post
Share on other sites
  • 0
Dr.Tautology

Hello,

I'm having a small issue with this batch. It works fine when I run manually as admin, but the batch does not run automatically on launch of viscosity. Any suggestions?

 

 

Edit:

Having done more research on it, it doesn't seem like this is really possible on Windows 7. I think you could write a wrapper script that elevates permissions via cmd and then runs the dns batch, but this will still require entering an admin password at least once. If you or anyone else has any suggestions they would be greatly appreciated. Otherwise running the batch manually gets the job done.

 

Edit Edit:

I've figured out how to write a wrapper script that allows powershell to bypass the execution policy and then run the dns batch. Tested it and it works perfectly. If anyone needs this let me know.

Share this post


Link to post
Share on other sites
  • 0
AusFlyGuy

Hi Jerry,

thanks for the post. The script was developed on Windows 7 and as far as I know works for most people.

Is your Windows 7 in a server/corporate environment?

Nonetheless I would be interested in the wrapper.

Thanks Ian.

Share this post


Link to post
Share on other sites
  • 0
Dr.Tautology

I'm on 64 bit Windows 7 Home Premium. The batch fails at the netsh commands stating that they require elevation, which makes sense. It even requires elevation just to look at the network adapter properties in control panel, so I would assume that needs to be bypassed to make changes to the adapters. I suppose some people have lax security in place on their Windows 7 machines which is why it works for them.

 

Anyway here is the wrapper. You would just edit the viscosity settings xml to point to this batch instead of TorGuard_ChgDNS.bat. Also, unless you specify a different path make sure the wrapper is in the same directory as the DNS.bat. It will still give the user account control prompt on launch, but that is just a matter of clicking "ok"; no passwords needed.

 

 

"C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe" -windowstyle hidden -nologo -noprofile -executionpolicy bypass -command "start-process -verb 'runas' -filepath C:TorGuard_ChgDNS.bat

 

 

 

One last thing, thank you very much for doing the leg work and writing this batch file. It's about as elegant as a Windows batch file gets ;)

Share this post


Link to post
Share on other sites
  • 0
newbietor231

Hi, would this work on Win 8.1? I'm a complete noob but think I could follow these instructions. I'm also trying to find a world without google so this is a great addition to an already fantastic piece of software. Thanks so much for doing all of this! :)

Share this post


Link to post
Share on other sites
  • 0
Phil

Loving this information. I am new to this and after reading about your batch file to get around google seems just great. Thanx a lot bud.

Share this post


Link to post
Share on other sites
  • 0
yIgD2

anyway to get this without having to create an accnt on MS One Drive?

 

edit:

 

dhcp-option DNS <dns server>
dhcp-option DNS <dns server>

 

i add the above lines to my *ovpn files. seems to work. probably not as elegant or efficient as that bat file.

Share this post


Link to post
Share on other sites
  • 0
yIgD2

or use TorGuard's private DNS-es all the time

i don't think i see that option with "...\VPNetwork LLC\TorGuard\TorGuardDesktopQt.exe"

Share this post


Link to post
Share on other sites
  • 0
Nick H

I would be interested in checking out this script. I don't think it in on that microsoft drive account anymore. Does anyone have this thing anymore? I would appreciate it if they could share.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...