diff --git a/GitHubIcon.png b/GitHubIcon.png new file mode 100644 index 0000000..6225ef0 Binary files /dev/null and b/GitHubIcon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/List of Secure DNS providers.txt b/List of Secure DNS providers.txt new file mode 100644 index 0000000..626d086 --- /dev/null +++ b/List of Secure DNS providers.txt @@ -0,0 +1,163 @@ +1dot1dot1dot1.cloudflare-dns.com +8888.google +a.ns.dnslify.com +adblock.mydns.network +adult-filter-dns.cleanbrowsing.org +b.ns.dnslify.com +canadianshield.cira.ca +chrome.cloudflare-dns.com +cloudflare-dns.com +cloudflare-gateway.com +commons.host +dns-family.adguard.com +dns-gcp.aaflalo.me +dns-nosec.quad9.net +dns-nyc.aaflalo.me +dns-unfiltered.adguard.com +dnsnl.alekberg.net +dns.233py.com +dns.233py.com.cdn.cloudflare.net +dns.aa.net.uk +dns.aaflalo.me +dns.adguard.com +dns.alekberg.net +dns.alidns.com +dns.bitgeek.in +dns.brahma.world +dns.cloudflare.com +dns.cmrg.net +dns.containerpi.co +dns.containerpi.com +dns.developer.li +dns.digitale-gesellschaft.ch +dns.dns-over-https.com +dns.dnsoverhttps.net +dns.flatuslifir.is +dns.google +dns.google.com +dns.hostux.net +dns.keweon.center +dns.larsdebruin.net +dns.neutopia.org +dns.nixnet.xyz +dns.pumplex.com +dns.quad9.net +dns.rubyfish.cn +dns.sb +dns.switch.ch +dns.t53.de +dns.twnic.tw +dns1.digitale-gesellschaft.ch +dns1.dnscrypt.ca +dns10.quad9.net +dns11.quad9.net +dns2.alekberg.net +dns2.developer.li +dns2.digitale-gesellschaft.ch +dns2.dnscrypt.ca +dns9.quad9.net +dnsforge.de +dnsotls.lab.nic.cl +dnsovertls.sinodun.com +dnsovertls1.sinodun.com +dnsovertls2.sinodun.com +dnsovertls3.sinodun.com +dnsse.alekberg.net +doh-01.spectrum.com +doh-02.spectrum.com +doh-2.seby.io +doh-ch.blahdns.com +doh-de.blahdns.com +doh-fi.blahdns.com +doh-ipv6.crypto.sx +doh-jp.blahdns.com +doh.233py.com +doh.42l.fr +doh.applied-privacy.net +doh.appliedprivacy.net +doh.armadillodns.net +doh.asecdns.com +doh.blahdns.com +doh.captnemo.in +doh.centraleu.pi-dns.com +doh.cleanbrowsing.org +doh.cox.net +doh.crypto.sx +doh.defaultroutes.de +doh.dns.apple.com +doh.dns.sb +doh.dnslify.com +doh.eastus.pi-dns.com +doh.familyshield.opendns.com +doh.ffmuc.net +doh.gslb2.xfinity.com +doh.li +doh.libredns.gr +doh.libredns.org +doh.netweaver.uk +doh.northeu.pi-dns.com +doh.opendns.com +doh.powerdns.org +doh.seby.io +doh.tiar.app +doh.tiarap.org +doh.westeu.pi-dns.com +doh.xfinity.com +dohdot.coxlab.net +dohtrial.att.net +dot-de.blahdns.com +dot-jp.blahdns.com +dot.asecdns.com +dot.cox.net +dot.quickline.ch +dot.xfinity.com +dot1.appliedprivacy.net +ea-dns.rubyfish.cn +example.doh.blockerdns.com +family-filter-dns.cleanbrowsing.org +family.cloudflare-dns.com +fi.doh.dns.snopyta.org +getdnsapi.net +google-public-dns-a.google.com +google-public-dns-b.google.com +i.233py.com.a.bdydns.com +iana.tenta.io +ibksturm.synology.me +ibuki.cgnat.net +jcdns.fun +jp.gridns.xyz +jp.tiar.app +jp.tiarap.org +kaitain.restena.lu +lux1.nixnet.xyz +lv1.nixnet.xyz +mozilla.cloudflare-dns.com +ndns.233py.com +ns1.dnsprivacy.at +ns2.dnsprivacy.at +ny1.nixnet.xyz +odvr.nic.cz +one.one.one.one +opencdn.jomodns.com +opennic.tenta.io +ordns.he.net +privacydns.go6lab.si +public-dns-a.dns.sb +public-dns-b.dns.sb +public.dns.iij.jp +rdns.faelix.net +resolver-eu.lelux.fi +resolver1-fs.opendns.com +resolver1.opendns.com +resolver2-fs.opendns.com +resolver2.opendns.com +rpz-public-resolver1.rrdns.pch.net +rumpelsepp.org +sdns.233py.com +security-filter-dns.cleanbrowsing.org +security.cloudflare-dns.com +tls-dns-u.odvr.dns-oarc.net +unicast.censurfridns.dk +unicast.uncensoreddns.org +uw-dns.rubyfish.cn +wdns.233py.com diff --git a/Module Operation Demo.apng b/Module Operation Demo.apng new file mode 100644 index 0000000..aa32fb3 Binary files /dev/null and b/Module Operation Demo.apng differ diff --git a/PowerShellGalleryIcon.png b/PowerShellGalleryIcon.png new file mode 100644 index 0000000..66f700b Binary files /dev/null and b/PowerShellGalleryIcon.png differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..c27b86b --- /dev/null +++ b/README.md @@ -0,0 +1,253 @@ +
+Avatar + +# WinSecureDNSMgr module + +Quick, proper and automatic way to configure Secure DNS in Windows with multiple available operation modes + +PowerShell Gallery + +Discussion +ยท +Report Issue + +![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/WinSecureDNSMgr?style=plastic&logo=powershell&labelColor=rgb(255%2C29%2C206)&color=rgb(201%2C255%2C229)) + +![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/WinSecureDNSMgr?style=plastic&labelColor=rgb(255%2C29%2C206)&color=rgb(201%2C255%2C229)) + +
+ +
+ Table of Contents + +1. Operation modes +2. About The Module +3. Features +4. Recommended setup +5. Prerequisites +6. Installation +7. Usage + - Built-in DoH examples + - Custom DoH examples + - Dynamic DoH examples + +
+ +
+ +horizontal super thin rainbow RGB line + +
+ +## Operation modes + +### DNS over HTTPS in Windows using the default built-in OS DoH providers + +* This is the default mode of operation for this module. It will set up DNS over HTTPS in Windows using the default built-in OS DoH providers, which are Cloudflare, Quad9 and Google. + +* In this mode of operation, the active network adapter/interface will be detected automatically but you will have the option to review it and choose a different one if you like. + +### DNS over HTTPS in Windows using a custom DoH provider that has **static** IP address(s) + +* This mode of operation is useful when you want to use a custom DoH provider that has static IP address(s). You can supply the module with a DoH template and then you have 2 options + + * Let the module automatically detect the IP address(s) of the DoH server and set them in Windows + * Supply the module with the IP address(s) of the DoH server and let it set them in Windows + +* In this mode of operation, the active network adapter/interface will be detected automatically but you will have the option to review it and choose a different one if you like. + +### DNS over HTTPS in Windows using a custom DoH provider that has **dynamic** IP address(s) + +* This mode of operation is useful when you want to use a custom DoH provider that has dynamic IP address(s). + +* Once you run the module in this mode for the first time and supply it with your DoH template, it will create a scheduled task that will run the module automatically based on 2 distinct criteria: + + - As soon as Windows detects the current DNS servers are unreachable + - Every 6 hours in order to check for new IP changes for the dynamic DoH server + + - You can fine-tune the interval in Task Scheduler GUI if you like. I haven't had any downtimes in my tests because the module runs milliseconds after Windows detects DNS servers are unreachable, and even then, Windows still maintains the current active connections using the DNS cache. if your experience is different, please let me know [on GitHub](https://github.com/HotCakeX/WinSecureDNSMgr/issues). + +* The module and the scheduled task will use both IPv4s and IPv6s of the dynamic DoH server. The task will run whether or not any user is logged on. + +* In this mode of operation, the active network adapter/interface will be detected automatically. + +
+ +

๐Ÿ’ก(back to top)

+ +
+ +horizontal super thin rainbow RGB line + +
+ +## About The Module + +This is a PowerShell module that can simplify setting up DNS over HTTPS in Windows for various scenarios mentioned in the Operation modes section. + +It can automatically identify the correct and active network adapter/interface and set Secure DNS settings for it based on parameters supplied by user. +That means it will detect the correct network adapter/interface even if you are using: + +- Windows built-in VPN connections (PPTP, L2TP, SSTP, IKEv2) +- OpenVPN +- TUN/TAP virtual adapters (a lot of programs use them, including WireGuard) +- Hyper-V virtual switches (Internal, Private, External, all at the same time) +- Cloudflare WARP client + +
+ +

๐Ÿ’ก(back to top)

+ +
+ +horizontal super thin rainbow RGB line + +
+ +## Features + + Strongest possible End-to-End encrypted workflow + + Created, targeted and tested on the latest version of Windows, on physical hardware and Virtual Machines + + To make sure the module will always be able to acquire the IP address(s) of the DoH server, specially in case of dynamic DoH server when the currently set system IPv4s and IPv6s might be outdated, the module performs DNS queries in this exact order: + + First tries using [Cloudflare's main encrypted API](https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/) to get the IP address(s) of the DoH server's domain. + + If 1st one fails, tries using the Cloudflare's secondary encrypted API to get the IP address(s) of the DoH server's domain. + + If 2nd one fails, tries using [Google's main encrypted API](https://developers.google.com/speed/public-dns/docs/doh/) to get the IP address(s) of the DoH server's domain. + + If 3rd one fails, tries using Google's secondary encrypted API to get the IP address(s) of the DoH server's domain. + + All of the connections to Cloudflare and Google servers use direct IP, are set to use [TLS 1.3](https://curl.se/docs/manpage.html#--tls13-ciphers) with [TLS_CHACHA20_POLY1305_SHA256](https://curl.se/docs/ssl-ciphers.html) cipher suite and use `HTTP/2` + +
+ +

๐Ÿ’ก(back to top)

+ +
+ +horizontal super thin rainbow RGB line + +
+ +## Recommended setup + +* Use Cloudflare DNS over HTTPS which is a built-in DoH provider in Windows, it's the safest, fastest and most reliable. + +* If you can't use publicly known DNS over HTTPS providers for any reason, you can create your own DoH server and domain for free using a [serverless Secure DNS](https://github.com/serverless-dns/serverless-dns) and [freenom](https://www.freenom.com/). They are more stealthy, hard or costly for ISPs, governments etc. to detect or block. + +
+ +

๐Ÿ’ก(back to top)

+ +
+ +horizontal super thin rainbow RGB line + +
+ +## Prerequisites + +* The latest stable version of PowerShell + * [Install it from GitHub](https://github.com/PowerShell/PowerShell/releases/latest) + * Using Winget `Winget install Microsoft.PowerShell` + * Store installed version of PowerShell is not supported for the Dynamic DoH (DDOH) operation mode. + +* Latest version of Windows + +If planning to use the module in dynamic DoH mode and it's the first time installing PowerShell on your machine, restart your computer after installation so task scheduler will recognize `pwsh.exe` required for running this module. + +
+ +

๐Ÿ’ก(back to top)

+ +
+ +horizontal super thin rainbow RGB line + +
+ +## Installation + +### Install from [PowerShell Gallery](https://www.powershellgallery.com/packages/WinSecureDNSMgr/) + +```powershell +Install-Module -Name WinSecureDNSMgr -force +``` + +
+ +if you already have the module installed, make sure [it's up-to-date](https://learn.microsoft.com/en-us/powershell/module/powershellget/update-module) + +```powershell +Update-Module -Name WinSecureDNSMgr -force +``` + +
+ +

๐Ÿ’ก(back to top)

+ +
+ +horizontal super thin rainbow RGB line + +
+ +## Usage + +
+ +![Animated APNG demonstrating how the Harden Windows Security PowerShell script works](https://github.com/HotCakeX/WinSecureDNSMgr/raw/main/Module%20Operation%20Demo.apng) + +
+ +### Built-in DoH examples + +```powershell +Set-BuiltInWinSecureDNS -DoHProvider Cloudflare +``` + +```powershell +Set-DOH -DoHProvider Cloudflare +``` + +
+ +### Custom DoH examples + +```powershell +Set-CustomWinSecureDNS -DoHTemplate https://example.com/ +``` + +```powershell +Set-CDOH -DoHTemplate https://example.com/ +``` + +```powershell +Set-CDOH -DoHTemplate https://example.com -IPV4s 1.2.3.4 -IPV6s 2001:db8::8a2e:370:7334 +``` + +
+ +### Dynamic DoH examples + +```powershell +Set-DynamicIPDoHServer -DoHTemplate https://example.com/ +``` + +```powershell +Set-DDOH -DoHTemplate https://example.com/ +``` + +
+ +

๐Ÿ’ก(back to top)

+ +
+ +## Upcoming features + +* DNS over TLS (DoT) support + * It's currently [only available in Windows insider builds](https://techcommunity.microsoft.com/t5/networking-blog/dns-over-tls-available-to-windows-insiders/bc-p/3714816), Dev and Canary channels. diff --git a/WinSecureDNSMgr/CommonResources.psm1 b/WinSecureDNSMgr/CommonResources.psm1 new file mode 100644 index 0000000..c0c8290 --- /dev/null +++ b/WinSecureDNSMgr/CommonResources.psm1 @@ -0,0 +1,95 @@ +function Select-Option { + param( + [parameter(Mandatory = $true, Position = 0)][string]$Message, + [parameter(Mandatory = $true, Position = 1)][string[]]$Options + ) + $Selected = $null + while ($null -eq $Selected) { + Write-Host $Message -ForegroundColor Magenta + for ($i = 0; $i -lt $Options.Length; $i++) { Write-Host "$($i+1): $($Options[$i])" } + $SelectedIndex = Read-Host "Select an option" + if ($SelectedIndex -gt 0 -and $SelectedIndex -le $Options.Length) { $Selected = $Options[$SelectedIndex - 1] } + else { Write-Host "Invalid Option." -ForegroundColor Yellow } + } + return $Selected +} + + +# we use --ssl-no-revoke because when system DNS is unreachable, CRL check will fail in cURL. +# it is OKAY, we're using trusted Cloudflare and Google servers the certificates of which explicitly mention their IP addresses (in Subject Alternative Name) that we are using to connect to them +Function Invoke-cURL { + param($url) + + # Enables "TLS_CHACHA20_POLY1305_SHA256" Cipher Suite for Windows 11, if necessary, because it's disabled by default + # cURL will need that cipher suite to perform encrypted DNS query, it uses Windows Schannel + if (-NOT ((Get-TlsCipherSuite).name -contains "TLS_CHACHA20_POLY1305_SHA256")) + { Enable-TlsCipherSuite -Name "TLS_CHACHA20_POLY1305_SHA256" } + + $IPs = curl --ssl-no-revoke --max-time 10 --tlsv1.3 --tls13-ciphers TLS_CHACHA20_POLY1305_SHA256 --http2 -H "accept: application/dns-json" $url; + $IPs = ( $IPs | ConvertFrom-Json).answer.data + return $IPs +} + +Function Get-IPv4DoHServerIPAddressWinSecureDNSMgr { + param ($domain) + + # get the new IPv4s for $domain + Write-Host "Using the main Cloudflare Encrypted API to resolve $domain" -ForegroundColor Green + $NewIPsV4 = Invoke-cURL "https://1.1.1.1/dns-query?name=$domain&type=A" + + if (!$NewIPsV4) { + Write-Host "First try failed, now using the secondary Encrypted Cloudflare API to to get IPv4s for $domain" -ForegroundColor Blue + $NewIPsV4 = Invoke-cURL "https://1.0.0.1/dns-query?name=$domain&type=A" + } + if (!$NewIPsV4) { + Write-Host "Second try failed, now using the main Encrypted Google API to to get IPv4s for $domain" -ForegroundColor Yellow + $NewIPsV4 = Invoke-cURL "https://8.8.8.8/resolve?name=$domain&type=A" + } + if (!$NewIPsV4) { + Write-Host "Third try failed, now using the second Encrypted Google API to to get IPv4s for $domain" -ForegroundColor DarkRed + $NewIPsV4 = Invoke-cURL "https://8.8.4.4/resolve?name=$domain&type=A" + } + + if ($NewIPsV4) { + return $NewIPsV4 + } + else { + Write-Host "`nFailed to get IPv4s for $domain" -ForegroundColor Red + return $null + } +} + +Function Get-IPv6DoHServerIPAddressWinSecureDNSMgr { + param ($domain) + + # get the new IPv6s for $domain + Write-Host "Using the main Cloudflare Encrypted API to resolve $domain" -ForegroundColor Green + $NewIPsV6 = Invoke-cURL "https://1.1.1.1/dns-query?name=$domain&type=AAAA" + + if (!$NewIPsV6) { + Write-Host "First try failed, now using the secondary Encrypted Cloudflare API to to get IPv6s for $domain" -ForegroundColor Blue + $NewIPsV6 = Invoke-cURL "https://1.0.0.1/dns-query?name=$domain&type=AAAA" + } + if (!$NewIPsV6) { + Write-Host "Second try failed, now using the main Encrypted Google API to to get IPv6s for $domain" -ForegroundColor Yellow + $NewIPsV6 = Invoke-cURL "https://8.8.8.8/resolve?name=$domain&type=AAAA" + } + if (!$NewIPsV6) { + Write-Host "Third try failed, now using the second Encrypted Google API to to get IPv6s for $domain" -ForegroundColor DarkRed + $NewIPsV6 = Invoke-cURL "https://8.8.4.4/resolve?name=$domain&type=AAAA" + } + + if ($NewIPsV6) { + return $NewIPsV6 + } + else { + Write-Host "`nFailed to get IPv6s for $domain" -ForegroundColor Red + return $null + } +} + +# Functions for custom color writing +function WriteViolet { Write-Host "$($PSStyle.Foreground.FromRGB(153,0,255))$($args[0])$($PSStyle.Reset)" -NoNewline } +function WritePink { Write-Host "$($PSStyle.Foreground.FromRGB(255,0,230))$($args[0])$($PSStyle.Reset)" -NoNewline } +function WriteLavender { Write-Host "$($PSStyle.Foreground.FromRgb(255,179,255))$($args[0])$($PSStyle.Reset)" -NoNewline } +function WriteTeaGreen { Write-Host "$($PSStyle.Foreground.FromRgb(133, 222, 119))$($args[0])$($PSStyle.Reset)" -NoNewline } diff --git a/WinSecureDNSMgr/Get-ActiveNetworkAdapterWinSecureDNS.psm1 b/WinSecureDNSMgr/Get-ActiveNetworkAdapterWinSecureDNS.psm1 new file mode 100644 index 0000000..5707f14 --- /dev/null +++ b/WinSecureDNSMgr/Get-ActiveNetworkAdapterWinSecureDNS.psm1 @@ -0,0 +1,54 @@ +function Get-ActiveNetworkAdapterWinSecureDNS { + try { + # get the currently active network interface/adapter that is being used for Internet access + # This gets the top most active adapter based on route metric + $ActiveNetworkInterface = Get-NetRoute -DestinationPrefix '0.0.0.0/0', '::/0' -ErrorAction SilentlyContinue | + Sort-Object -Property { $_.InterfaceMetric + $_.RouteMetric } -Top 1 -PipelineVariable ActiveAdapter | + Get-NetAdapter -ErrorAction SilentlyContinue | Where-Object { $_.ifIndex -eq $ActiveAdapter.ifIndex } + + # check if the top most active adapter that we got has an interface index + # Windows built-in VPN client connections don't have interface index and don't appear in Get-Netadapter results + if (!$ActiveNetworkInterface) { + Write-Debug "This adapter doesn't even exist in get-Netadapter results and doesn't have interface index, must be built-in Windows VPN client adapter" + # then we get the 2nd adapter from the top + $ActiveNetworkInterface = Get-NetRoute -DestinationPrefix '0.0.0.0/0', '::/0' -ErrorAction SilentlyContinue | + Sort-Object -Property { $_.InterfaceMetric + $_.RouteMetric } -Top 2 | + Select-Object -skip 1 | select-Object -first 1 -PipelineVariable ActiveAdapter | + Get-NetAdapter | Where-Object { $_.ifIndex -eq $ActiveAdapter.ifIndex } + } + # if the top most adapter that we got has an interface index + else { + # check if the detected active interface from the previous step is virtual, if it is, checks if it's an external virtual Hyper-V network adapter or VPN virtual network adapter + if ((Get-NetAdapter | Where-Object { $_.InterfaceGuid -eq $ActiveNetworkInterface.InterfaceGuid }).Virtual) { + Write-Debug "Interface is virtual, trying to find out if it's a VPN virtual adapter or Hyper-V External virtual switch" + + # if it's an external virtual Hyper-V network adapter, it must be the correct adapter + if ($ActiveNetworkInterface.InterfaceDescription -like "*Hyper-V Virtual Ethernet Adapter*" ) { + Write-Debug "The detected active network adapter is virtual, it's Hyper-V External switch" + $ActiveNetworkInterface = $ActiveNetworkInterface + } + # if the detected active network adapter is virtual but Not virtual external Hyper-V network adapter, which means it is VPN virtual network adapter (but not Windows built-in VPN client), + # choose the second prioritized adapter/interface based on route metric + # tested with Cloudflare WARP (that doesn't create a separate adapter), Wintun, TAP, OpenVPN and has been always successful in detecting the correct network adapter/interface + else { + Write-Debug "Detected active network adapter is virtual but not virtual Hyper-V adapter, most likely a VPN virtual network adapter, choosing the second prioritized adapter/interface based on route metric" + $ActiveNetworkInterface = Get-NetRoute -DestinationPrefix '0.0.0.0/0', '::/0' -ErrorAction SilentlyContinue | + Sort-Object -Property { $_.InterfaceMetric + $_.RouteMetric } -Top 2 | + select-Object -skip 1 | select-Object -first 1 -PipelineVariable ActiveAdapter | + Get-NetAdapter | Where-Object { $_.ifIndex -eq $ActiveAdapter.ifIndex } + } + } + } + Write-Debug "This is the automatically detected network adapter this script is going to set Secure DNS for" + return $ActiveNetworkInterface + } + catch { + $_ + $_.Exception + break + } +} + +# luckily, it's not normally possible to change description of network interfaces/adapters +# so it is a solid criteria for choosing our network adapter/interface +# https://serverfault.com/questions/862065/changing-nic-interface-descriptions-in-windows#:~:text=You%20can%27t%20change%20the%20name%20of%20the%20NICs,you%27ll%20have%20to%20do%20lots%20of%20name%20swapping diff --git a/WinSecureDNSMgr/Get-ManualNetworkAdapterWinSecureDNS.psm1 b/WinSecureDNSMgr/Get-ManualNetworkAdapterWinSecureDNS.psm1 new file mode 100644 index 0000000..c27ce8e --- /dev/null +++ b/WinSecureDNSMgr/Get-ManualNetworkAdapterWinSecureDNS.psm1 @@ -0,0 +1,92 @@ +function Get-ManualNetworkAdapterWinSecureDNS { + + # Get the network adapters and their properties if their status is neither disabled, disconnected nor null + $Adapters = Get-NetAdapter | Where-Object { $_.Status -ne 'Disabled' -and $null -ne $_.Status -and $_.Status -ne 'Disconnected' } + # Get the maximum length of each property for formatting the output + $NameLength = ($Adapters.Name | Measure-Object -Maximum -Property Length).Maximum + 2 + $DescriptionLength = ($Adapters.InterfaceDescription | Measure-Object -Maximum -Property Length).Maximum + 2 + $MacLength = ($Adapters.MacAddress | Measure-Object -Maximum -Property Length).Maximum + 2 + # Not used because manually setting the width for it + # $StatusLength = ($Adapters.Status | Measure-Object -Maximum -Property Length).Maximum + 2 + $LinkLength = ($Adapters.LinkSpeed | Measure-Object -Maximum -Property Length).Maximum + 2 + + # Creating a heading for the columns + # Write the index of the adapter + WriteLavender ("{0,-5}" -f "#") + # Write the name of the adapter in cyan + WriteTeaGreen ("|{0,-$NameLength}" -f "Name") + # Write the interface description of the adapter in yellow + WritePink ("|{0,-$DescriptionLength}" -f "Description") + # Write the MAC address of the adapter in green + WriteViolet ("|{0,-$MacLength}" -f "Mac Addr") + # Write the status of the adapter in red + Write-Host ("|{0,-8}" -f "Status") -NoNewline -ForegroundColor Red + # Write the link speed of the adapter in magenta + Write-Host ("|{0,-$LinkLength}" -f "Speed") -ForegroundColor Magenta + + # Loop through the adapters and display them in a table with colors + for ($i = 0; $i -lt $Adapters.Count; $i++) { + # Write the index of the adapter + WriteLavender ("{0,-5}" -f ($i + 1)) + # Write the name of the adapter in cyan + WriteTeaGreen ("|{0,-$NameLength}" -f $Adapters[$i].Name) + # Write the interface description of the adapter in yellow + WritePink ("|{0,-$DescriptionLength}" -f $Adapters[$i].InterfaceDescription) + # Write the MAC address of the adapter in green + WriteViolet ("|{0,-$MacLength}" -f $Adapters[$i].MacAddress) + # Write the status of the adapter in red + Write-Host ("|{0,-8}" -f $Adapters[$i].Status) -NoNewline -ForegroundColor Red + # Write the link speed of the adapter in magenta + Write-Host ("|{0,-$LinkLength}" -f $Adapters[$i].LinkSpeed) -ForegroundColor Magenta + } + + # Get the max count of available network adapters and add 1 to it, assign the number as exit value to break the loop when selected + $ExitCodeAdapterSelection = $Adapters.Count + 1 + + # Write an exit option at the end of the table + Write-Host ("{0,-5}" -f "$ExitCodeAdapterSelection") -NoNewline -ForegroundColor DarkRed + Write-Host "|Cancel" -ForegroundColor DarkRed + + # Define a function to validate the user input + function Confirm-Choice { + param($Choice) + # Get an array of valid numbers from 1 to $ExitCodeAdapterSelection + $ValidNumbers = 1..$ExitCodeAdapterSelection + # Initialize a flag to indicate if the input is valid or not + $IsValid = $false + # Loop through each valid number and compare it with the input + foreach ($Number in $ValidNumbers) { + # If the input is equal to a valid number, set the flag to true and break the loop + if ($Choice -eq $Number) { + $IsValid = $true + break + } + } + # Return the flag value + return $IsValid + } + + # Prompt the user to enter the number of the adapter they want to select, or exit value to exit, until they enter a valid input + do { + $Choice = Read-Host "Enter the number of the adapter you want to select or press $ExitCodeAdapterSelection to Cancel`n" + # Check if the input is valid using the Confirm-Choice function + if (-not (Confirm-Choice $Choice)) { + # Write an error message in red if invalid + Write-Host "Invalid input. Please enter a number between 1 and $ExitCodeAdapterSelection." -ForegroundColor Red + } + } while (-not (Confirm-Choice $Choice)) + + # Check if the user entered the exit value to break out of the loop + if ($Choice -eq $ExitCodeAdapterSelection) { + # Write a message in white and break out of the loop + Write-Host "Exiting..." -ForegroundColor Magenta + # Send False flag to the caller function to indicate that the user cancelled the operation + return $false + break + } + else { + # Get the selected adapter from the array and display it + $ActiveNetworkInterface = $Adapters[$Choice - 1] + return $ActiveNetworkInterface + } +} diff --git a/WinSecureDNSMgr/Set-BuiltInWinSecureDNS.psm1 b/WinSecureDNSMgr/Set-BuiltInWinSecureDNS.psm1 new file mode 100644 index 0000000..64533bb --- /dev/null +++ b/WinSecureDNSMgr/Set-BuiltInWinSecureDNS.psm1 @@ -0,0 +1,119 @@ +Function Set-BuiltInWinSecureDNS { + [Alias("Set-DOH")] + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + [ValidateSet('Cloudflare', 'Google', 'Quad9', ErrorMessage = "The selected DNS over HTTPS provider is not supported by Windows. Please select a different provider or use the Set-CustomWinSecureDNS cmdlet.")] + [Parameter(Mandatory)][string]$DoHProvider + ) + begin { + + Switch ($DoHProvider) { + "cloudflare" { + $DetectedDoHTemplate = "https://cloudflare-dns.com/dns-query" + } + "Google" { + $DetectedDoHTemplate = "https://dns.google/dns-query" + } + "Quad9" { + $DetectedDoHTemplate = "https://dns.quad9.net/dns-query" + } + } + + if (-NOT ((Get-DnsClientDohServerAddress | Where-Object { $_.DohTemplate -eq $DetectedDoHTemplate }).DohTemplate) ) { + throw "The DNS over HTTPS provider $DoHProvider is not supported by Windows. Please select a different provider." + } + + # Automatically detect the correct network adapter + $ActiveNetworkInterface = Get-ActiveNetworkAdapterWinSecureDNS + $ActiveNetworkInterface + + # loop until the user confirms the detected adapter is the correct one, Selects the correct network adapter or Cancels + switch (Select-Option -Options "Yes", "No - Select Manually", "Cancel" -Message "`nIs the detected network adapter correct ?") { + "Yes" { + $ActiveNetworkInterface = $ActiveNetworkInterface + } + "No - Select Manually" { + $ActiveNetworkInterface = Get-ManualNetworkAdapterWinSecureDNS + } # properly exiting this advanced function is a bit tricky, so we use a variable to control the loop + "Cancel" { $ShouldExit = $true; return } + } + + # if user chose to cancel the Get-ManualNetworkAdapterWinSecureDNS function, set the $shouldExit variable to $true and exit the function in the Process block + if (!$ActiveNetworkInterface) { $ShouldExit = $true; return } + } + + process { + # if the user selected Cancel, do not proceed with the process block + if ($ShouldExit) { break } + + # reset the network adapter's DNS servers back to default to take care of any IPv6 strays + Set-DnsClientServerAddress -InterfaceIndex $ActiveNetworkInterface.ifIndex -ResetServerAddresses -ErrorAction Stop + + # delete all other previous DoH settings for ALL Interface - Windows behavior in settings when changing DoH settings is to delete all DoH settings for the interface we are modifying + # but we need to delete all DoH settings for ALL interfaces in here because every time we virtualize a network adapter with external switch of Hyper-V, + # Hyper-V assigns a new GUID to it, so it's better not to leave any leftover in the registry and clean up after ourselves + Remove-item "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\*" -Recurse | Out-Null + + $DoHIPs = (Get-DnsClientDohServerAddress | Where-Object { $_.DohTemplate -eq $DetectedDoHTemplate }).ServerAddress + + $DoHIPs | ForEach-Object { + + # use the ipaddress type accelerator to check if the address is IPv4 or IPv6 + $IP = [ipaddress]$_ + if ($IP.AddressFamily -eq 'InterNetwork') { + # defining registry path for DoH settings of the $ActiveNetworkInterface based on its GUID for IPv4 + $Path = "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$($ActiveNetworkInterface.InterfaceGuid)\DohInterfaceSettings\Doh\$_" + + # add DoH settings for the specified Network adapter based on its GUID in registry + # value 1 for DohFlags key means use automatic template for DoH, 2 means manual template, since we add our template to Windows, it's predefined so we use value 1 + New-Item -Path $Path -Force | Out-Null + New-ItemProperty -Path $Path -Name "DohFlags" -Value 1 -PropertyType Qword -Force + + Set-DnsClientDohServerAddress -ServerAddress $_ -DohTemplate $DetectedDoHTemplate -AllowFallbackToUdp $False -AutoUpgrade $True + } + elseif ($IP.AddressFamily -eq 'InterNetworkV6') { + # defining registry path for DoH settings of the $ActiveNetworkInterface based on its GUID for IPv6 + $Path = "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$($ActiveNetworkInterface.InterfaceGuid)\DohInterfaceSettings\Doh6\$_" + + # add DoH settings for the specified Network adapter based on its GUID in registry + # value 1 for DohFlags key means use automatic template for DoH, 2 means manual template, since we already added our template to Windows, it's considered predefined, so we use value 1 + New-Item -Path $Path -Force | Out-Null + New-ItemProperty -Path $Path -Name "DohFlags" -Value 1 -PropertyType Qword -Force + + Set-DnsClientDohServerAddress -ServerAddress $_ -DohTemplate $DetectedDoHTemplate -AllowFallbackToUdp $False -AutoUpgrade $True + } + } + + # this is responsible for making the changes in Windows settings UI > Network and internet > $ActiveNetworkInterface.Name + Set-DnsClientServerAddress -ServerAddresses $DoHIPs -InterfaceIndex $ActiveNetworkInterface.ifIndex -ErrorAction Stop + } + + end { + # clear DNS client Cache + Clear-DnsClientCache + + Write-Host "`nDNS over HTTPS (DoH) is now configured for $($ActiveNetworkInterface.Name) using $DoHProvider provider.`n" -ForegroundColor Green + } + + <# +.SYNOPSIS +Easily and quickly configure DNS over HTTPS (DoH) in Windows + +.LINK +https://github.com/HotCakeX/WinSecureDNSMgr + +.DESCRIPTION +Easily and quickly configure DNS over HTTPS (DoH) in Windows + +.FUNCTIONALITY +Using official Microsoft methods configures DNS over HTTPS in Windows + +.PARAMETER DoHProvider +The name of the 3 built-in DNS over HTTPS providers: Cloudflare, Google and Quad9 + +.EXAMPLE +Set-BuiltInWinSecureDNS -DoHProvider Cloudflare +Set-DOH -DoHProvider Cloudflare + +#> +} diff --git a/WinSecureDNSMgr/Set-CustomWinSecureDNS.psm1 b/WinSecureDNSMgr/Set-CustomWinSecureDNS.psm1 new file mode 100644 index 0000000..cef99b0 --- /dev/null +++ b/WinSecureDNSMgr/Set-CustomWinSecureDNS.psm1 @@ -0,0 +1,177 @@ +function Set-CustomWinSecureDNS { + [Alias("Set-CDOH")] + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + # checking to make sure the DoH template is valid and not one of the built-in ones + [ValidatePattern("^https\:\/\/.+\..+\/.*", ErrorMessage = "The value provided for the parameter DoHTemplate is not a valid DNS over HTTPS template. Please enter a valid DNS over HTTPS template that starts with https, has a TLD and a slash after it. E.g.: https://template.com/")] + [ValidateScript({ $_ -notmatch "https://(cloudflare-dns|dns\.google|dns\.quad9)\.com/dns-query" }, ErrorMessage = "The DoH template you selected is one of the Windows built-in ones. Please select a different DoH template or use the Set-BuiltInWinSecureDNS cmdlet.")] + [Parameter(Mandatory)][string]$DoHTemplate, + + # The parameter can either accept 1 or 2 IPv4 addresses + [ValidateCount(1, 2)][ipaddress[]]$IPV4s, + + # The parameter can either accept 1 or 2 IPv6 addresses + [ValidateCount(1, 2)][ipaddress[]]$IPV6s + ) + begin { + + $AutoDetectDoHIPs = $false + + # If IP addresses were provided manually by user, verify their version + if ($IPV4s) { + $IPV4s | ForEach-Object { if ($_.AddressFamily -ne "InterNetwork") { throw "The IP address $_ is not a valid IPv4 address." } } + } + if ($IPV6s) { + $IPV6s | ForEach-Object { if ($_.AddressFamily -ne "InterNetworkV6") { throw "The IP address $_ is not a valid IPv6 address." } } + } + + # if no IP addresses were provided manually by user, set the $AutoDetectDoHIPs variable to $true + if (!$IPV4s -and !$IPV6s) { + $AutoDetectDoHIPs = $true + } + + # Detect the active network adapter automatically + $ActiveNetworkInterface = Get-ActiveNetworkAdapterWinSecureDNS + $ActiveNetworkInterface + + switch (Select-Option -Options "Yes", "No - Select Manually", "Cancel" -Message "`nIs the detected network adapter correct ?") { + "Yes" { + $ActiveNetworkInterface = $ActiveNetworkInterface + } + "No - Select Manually" { + # Detect the active network adapter manually + $ActiveNetworkInterface = Get-ManualNetworkAdapterWinSecureDNS + } # properly exiting this advanced function is a bit tricky, so we use a variable to control the loop + "Cancel" { $ShouldExit = $true; return } + } + + # if user chose to cancel the Get-ManualNetworkAdapterWinSecureDNS function, set the $shouldExit variable to $true and exit the function in the Process block + if (!$ActiveNetworkInterface) { $ShouldExit = $true; return } + + # Detect the IP address(s) of the DoH domain automatically if not provided by the user + if ($AutoDetectDoHIPs) { + + # Define the regex for extracting the domain name + $DomainExtractionRegex = '(?<=https\:\/\/).+?(?=\/)' + + # Test if the input matches the regex + $DoHTemplate -match $DomainExtractionRegex + # Access the matched value + $domain = $Matches[0] + + Write-Debug -Message "The extracted domain name is $domain`n" + # Get the IP addresses of the DoH domain + $IPV4s = Get-IPv4DoHServerIPAddressWinSecureDNSMgr -Domain $domain + $IPV6s = Get-IPv6DoHServerIPAddressWinSecureDNSMgr -Domain $domain + + # If no IP addresses were found for either versions, exit the function + if ($null -eq $IPV4s -and $null -eq $IPV6s) { + Write-Error -Message "`nNo IP addresses were found for the domain $domain. Please make sure the domain is valid and try again, alternatively you can use the Set-BuiltInWinSecureDNS cmdlet to set one of the built-in DoH templates." + $ShouldExit = $true; return + } + } + } + process { + + # if the user selected Cancel, do not proceed with the process block + if ($ShouldExit) { break } + + # check if there is any IP address already associated with "$DoHTemplate" template + $oldIPs = (Get-DnsClientDohServerAddress | Where-Object { $_.dohTemplate -eq $DoHTemplate }).serveraddress + # if there is, remove them + if ($oldIPs) { + $oldIPs | ForEach-Object { + remove-DnsClientDohServerAddress -ServerAddress $_ + } + } + + # check if the IP addresses of the currently selected domain already exist and then delete them + Get-DnsClientDohServerAddress | ForEach-Object { + if ($_.ServerAddress -in $IPV4s -or $_.ServerAddress -in $IPV6s) { + remove-DnsClientDohServerAddress -ServerAddress $_.ServerAddress + $_ + } + } + + # reset the network adapter's DNS servers back to default to take care of any IPv6 strays + Set-DnsClientServerAddress -InterfaceIndex $ActiveNetworkInterface.ifIndex -ResetServerAddresses -ErrorAction Stop + + # delete all other previous DoH settings for ALL Interface - Windows behavior in settings when changing DoH settings is to delete all DoH settings for the interface we are modifying + # but we need to delete all DoH settings for ALL interfaces in here because every time we virtualize a network adapter with external switch of Hyper-V, + # Hyper-V assigns a new GUID to it, so it's better not to leave any leftover in the registry and clean up after ourselves + Remove-item "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\*" -Recurse + + if ($null -ne $IPV4s) { + # loop through each IPv4 + $IPV4s | foreach-Object { + # defining registry path for DoH settings of the $ActiveNetworkInterface based on its GUID for IPv4 + $Path = "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$($ActiveNetworkInterface.InterfaceGuid)\DohInterfaceSettings\Doh\$_" + # associating the new IPv4s with our DoH template in Windows DoH template predefined list + Add-DnsClientDohServerAddress -ServerAddress $_ -DohTemplate $DoHTemplate -AllowFallbackToUdp $False -AutoUpgrade $True + # add DoH settings for the specified Network adapter based on its GUID in registry + # value 1 for DohFlags key means use automatic template for DoH, 2 means manual template, since we add our template to Windows, it's predefined so we use value 1 + New-Item -Path $Path -Force | Out-Null + New-ItemProperty -Path $Path -Name "DohFlags" -Value 1 -PropertyType Qword -Force + } + } + + # Making sure the DoH server supports and has IPv6 addresses + if ($null -ne $IPV6s) { + # loop through each IPv6 + $IPV6s | foreach-Object { + # defining registry path for DoH settings of the $ActiveNetworkInterface based on its GUID for IPv6 + $Path = "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$($ActiveNetworkInterface.InterfaceGuid)\DohInterfaceSettings\Doh6\$_" + # associating the new IPv6s with our DoH template in Windows DoH template predefined list + Add-DnsClientDohServerAddress -ServerAddress $_ -DohTemplate $DoHTemplate -AllowFallbackToUdp $False -AutoUpgrade $True + # add DoH settings for the specified Network adapter based on its GUID in registry + # value 1 for DohFlags key means use automatic template for DoH, 2 means manual template, since we already added our template to Windows, it's considered predefined, so we use value 1 + New-Item -Path $Path -Force | Out-Null + New-ItemProperty -Path $Path -Name "DohFlags" -Value 1 -PropertyType Qword -Force + } + } + # gather IPv4s and IPv6s all in one place + $NewIPs = $IPV4s + $IPV6s + + # this is responsible for making the changes in Windows settings UI > Network and internet > $ActiveNetworkInterface.Name + Set-DnsClientServerAddress -ServerAddresses $NewIPs -InterfaceIndex $ActiveNetworkInterface.ifIndex -ErrorAction Stop + + } + + end { + # clear DNS client Cache + Clear-DnsClientCache + + Write-Host "`nDNS over HTTPS has been successfully configured for $($ActiveNetworkInterface.Name) using $DoHTemplate template.`n" -ForegroundColor Green + } + <# +.SYNOPSIS +This script is a wrapper around the official Microsoft methods to configure DNS over HTTPS in Windows + +.LINK +https://github.com/HotCakeX/WinSecureDNSMgr + +.DESCRIPTION +This script is a wrapper around the official Microsoft methods to configure DNS over HTTPS in Windows. +If no IP address is provided for the DoH template, they will be detected automatically. + +.FUNCTIONALITY +Using official Microsoft methods configures DNS over HTTPS in Windows + +.PARAMETER DoHProvider +The name of the 3 built-in DNS over HTTPS providers: Cloudflare, Google and Quad9 + +.PARAMETER DoHTemplate +Enter a custom DoH template URL that starts with https, has a TLD and a slash after it. E.g.: https://template.com/" + +.PARAMETER IPV4s +Enter 1 or 2 IPv4 and/or IPv6 addresses separated by comma + +.PARAMETER IPV6s +Enter 1 or 2 IPv4 and/or IPv6 addresses separated by comma + +.EXAMPLE +Set-CustomWinSecureDNS -DoHTemplate https://example.com/ +Set-CDOH -DoHTemplate https://example.com -IPV4s 1.2.3.4 -IPV6s 2001:db8::8a2e:370:7334 + +#> +} diff --git a/WinSecureDNSMgr/Set-DynamicIPDoHServer.psm1 b/WinSecureDNSMgr/Set-DynamicIPDoHServer.psm1 new file mode 100644 index 0000000..334344c --- /dev/null +++ b/WinSecureDNSMgr/Set-DynamicIPDoHServer.psm1 @@ -0,0 +1,161 @@ +function Set-DynamicIPDoHServer { + [Alias("Set-DDOH")] + [CmdletBinding(SupportsShouldProcess = $true)] + param ( + # checking to make sure the DoH template is valid and not one of the built-in ones + [ValidatePattern("^https\:\/\/.+\..+\/.*", ErrorMessage = "The value provided for the parameter DoHTemplate is not a valid DNS over HTTPS template. Please enter a valid DNS over HTTPS template that starts with https, has a TLD and a slash after it. E.g.: https://template.com/")] + [ValidateScript({ $_ -notmatch "https://(cloudflare-dns|dns\.google|dns\.quad9)\.com/dns-query" }, ErrorMessage = "The DoH template you selected is one of the Windows built-in ones. Please select a different DoH template or use the Set-BuiltInWinSecureDNS cmdlet.")] + [Parameter(Mandatory)][string]$DoHTemplate + ) + + begin { + + # Define the regex for extracting the domain name + $DomainExtractionRegex = '(?<=https\:\/\/).+?(?=\/)' + + # Test if the input matches the regex + $DoHTemplate -match $DomainExtractionRegex + # Access the matched value + $domain = $Matches[0] + + Write-Debug -Message "The extracted domain name is $domain`n" + + } + + process { + + # error handling for the entire function - to make sure there is no error before attempting to create the scheduled task + try { + + $ActiveNetworkInterface = Get-ActiveNetworkAdapterWinSecureDNS + Write-host "This is the final detected network adapter this module is going to set Secure DNS for" -ForegroundColor DarkMagenta + $ActiveNetworkInterface + + # check if there is any IP address already associated with "$DoHTemplate" template + $oldIPs = (Get-DnsClientDohServerAddress | Where-Object { $_.dohTemplate -eq $DoHTemplate }).serveraddress + # if there is, remove them + if ($oldIPs) { + $oldIPs | ForEach-Object { + Remove-DnsClientDohServerAddress -ServerAddress $_ + } + } + + # reset the network adapter's DNS servers back to default to take care of any IPv6 strays + Set-DnsClientServerAddress -InterfaceIndex $ActiveNetworkInterface.ifIndex -ResetServerAddresses -ErrorAction Stop + + # delete all other previous DoH settings for ALL Interface - Windows behavior in settings when changing DoH settings is to delete all DoH settings for the interface we are modifying + # but we need to delete all DoH settings for ALL interfaces in here because every time we virtualize a network adapter with external switch of Hyper-V, + # Hyper-V assigns a new GUID to it, so it's better not to leave any leftover in the registry and clean up after ourselves + Remove-item "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\*" -Recurse + + $NewIPsV4 = Get-IPv4DoHServerIPAddressWinSecureDNSMgr -Domain $domain + + # loop through each IPv4 + $NewIPsV4 | foreach-Object { + # defining registry path for DoH settings of the $ActiveNetworkInterface based on its GUID for IPv4 + $Path = "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$($ActiveNetworkInterface.InterfaceGuid)\DohInterfaceSettings\Doh\$_" + # associating the new IPv4s with our DoH template in Windows DoH template predefined list + Add-DnsClientDohServerAddress -ServerAddress $_ -DohTemplate $DoHTemplate -AllowFallbackToUdp $False -AutoUpgrade $True + # add DoH settings for the specified Network adapter based on its GUID in registry + # value 1 for DohFlags key means use automatic template for DoH, 2 means manual template, since we add our template to Windows, it's predefined so we use value 1 + New-Item -Path $Path -Force | Out-Null + New-ItemProperty -Path $Path -Name "DohFlags" -Value 1 -PropertyType Qword -Force + } + + $NewIPsV6 = Get-IPv6DoHServerIPAddressWinSecureDNSMgr -Domain $domain + + # loop through each IPv6 + $NewIPsV6 | foreach-Object { + # defining registry path for DoH settings of the $ActiveNetworkInterface based on its GUID for IPv6 + $Path = "HKLM:System\CurrentControlSet\Services\Dnscache\InterfaceSpecificParameters\$($ActiveNetworkInterface.InterfaceGuid)\DohInterfaceSettings\Doh6\$_" + # associating the new IPv6s with our DoH template in Windows DoH template predefined list + Add-DnsClientDohServerAddress -ServerAddress $_ -DohTemplate $DoHTemplate -AllowFallbackToUdp $False -AutoUpgrade $True + # add DoH settings for the specified Network adapter based on its GUID in registry + # value 1 for DohFlags key means use automatic template for DoH, 2 means manual template, since we already added our template to Windows, it's considered predefined, so we use value 1 + New-Item -Path $Path -Force | Out-Null + New-ItemProperty -Path $Path -Name "DohFlags" -Value 1 -PropertyType Qword -Force + } + + # gather IPv4s and IPv6s all in one place + $NewIPs = $NewIPsV4 + $NewIPsV6 + + # this is responsible for making the changes in Windows settings UI > Network and internet > $ActiveNetworkInterface.Name + Set-DnsClientServerAddress -ServerAddresses $NewIPs -InterfaceIndex $ActiveNetworkInterface.ifIndex -ErrorAction Stop + # clear DNS client Cache + Clear-DnsClientCache + } + + catch { + Write-host "these errors occured after running the module" -ForegroundColor white + $_ + $ModuleErrors = $_ + } + + } + + end { + + # here we enable logging for the event log below (which is disabled by default) and set its log size from the default 1MB to 2MB + $LogName = 'Microsoft-Windows-DNS-Client/Operational' + + $Log = New-Object System.Diagnostics.Eventing.Reader.EventLogConfiguration $LogName + $Log.MaximumSizeInBytes = 2048000 + $Log.IsEnabled = $true + $Log.SaveChanges() + if (!$ModuleErrors) { + + Write-Debug "No errors occured when running the module, creating the scheduled task now if it's not already been created" + + # create a scheduled task + $Action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument "-executionPolicy bypass -command `"Set-DynamicIPDoHServer -DoHTemplate '$DoHTemplate'`"" + $TaskPrincipal = New-ScheduledTaskPrincipal -LogonType S4U -UserId $env:USERNAME -RunLevel Highest + # trigger 1 + $CIMTriggerClass = + Get-CimClass -ClassName MSFT_TaskEventTrigger -Namespace Root/Microsoft/Windows/TaskScheduler:MSFT_TaskEventTrigger + $EventTrigger = New-CimInstance -CimClass $CIMTriggerClass -ClientOnly + $EventTrigger.Subscription = + @" + +"@ + $EventTrigger.Enabled = $True + $EventTrigger.ExecutionTimeLimit = "PT1M" + # trigger 2 + $Time = + New-ScheduledTaskTrigger ` + -Once -At (Get-Date).AddHours(3) ` + -RandomDelay (New-TimeSpan -Seconds 30) ` + -RepetitionInterval (New-TimeSpan -Hours 6) ` + # register the task + Register-ScheduledTask -Action $Action -Trigger $EventTrigger, $Time -Principal $TaskPrincipal -TaskPath "DDoH" -TaskName "Dynamic DoH Server IP check" -Description "Checks for New IPs of our Dynamic DoH server" -Force + # define advanced settings for the task + $TaskSettings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -Compatibility Win8 -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Minutes 1) + # add advanced settings we defined to the task + Set-ScheduledTask -TaskPath "DDoH" -TaskName "Dynamic DoH Server IP check" -Settings $TaskSettings + + } + } + + + <# +.SYNOPSIS +Use a DNS over HTTPS (DoH) server with a dynamic IP address in Windows + +.LINK +https://github.com/HotCakeX/WinSecureDNSMgr + +.DESCRIPTION +Easily use a DNS over HTTPS (DoH) server with a dynamic IP address in Windows + +.FUNCTIONALITY +Sets a DNS over HTTPS (DoH) server in Windows DNS client settings and adds the DoH server to the Windows DoH template predefined list. +It then updates the DoH server IP address in Windows DNS client settings whenever the IP address of the DoH server changes. + +.PARAMETER DoHTemplate +The DNS over HTTPS template of the server that has a dynamic IP address + +.EXAMPLE +Set-DDOH -DoHTemplate https://example.com/ +Set-DynamicIPDoHServer -DoHTemplate https://example.com/ + +#> +} diff --git a/WinSecureDNSMgr/WinSecureDNSMgr.psd1 b/WinSecureDNSMgr/WinSecureDNSMgr.psd1 new file mode 100644 index 0000000..93dcd3f --- /dev/null +++ b/WinSecureDNSMgr/WinSecureDNSMgr.psd1 @@ -0,0 +1,183 @@ +# +# Module manifest for module 'WinSecureDNSMgr' +# +# Generated by: HotCakeX +# +# Generated on: 6/23/2023 +# + +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'WinSecureDNSMgr.psm1' + + # Version number of this module. + ModuleVersion = '0.0.3' + + # Supported PSEditions + CompatiblePSEditions = @("Core") + + # ID used to uniquely identify this module + GUID = 'e8b709e5-6ccc-471c-9625-edf2bca4ebee' + + # Author of this module + Author = 'HotCakeX' + + # Company or vendor of this module + CompanyName = 'SpyNetGirl' + + # Copyright statement for this module + Copyright = '(c) HotCakeX. All rights reserved.' + + # Description of the functionality provided by this module + Description = @" + + +๐Ÿ’Ž This is a PowerShell module that can simplify setting up DNS over HTTPS in Windows for various scenarios ๐Ÿ’Ž + + +๐Ÿ”ท DNS over HTTPS in Windows using the default built-in OS DoH providers +๐Ÿ”ท DNS over HTTPS in Windows using a custom DoH provider that has static IP address(s) +๐Ÿ”ท DNS over HTTPS in Windows using a custom DoH provider that has dynamic IP address(s) + + +It can automatically identify the correct and active network adapter/interface and set Secure DNS settings for it based on parameters supplied by user. + + +โœ… Features + +โœ… Strongest possible End-to-End encrypted workflow + +โœ… Created, targeted and tested on the latest version of Windows, on physical hardware and Virtual Machines + +โœ… To make sure the module will always be able to acquire the IP address(s) of the DoH server, specially in case of dynamic DoH server when the currently set system IPv4s and IPv6s might be outdated, the module performs DNS queries in this exact order: + +โœ… - First tries using Cloudflare's main encrypted API to get the IP address(s) of the DoH server's domain. +โœ… - If 1st one fails, tries using the Cloudflare's secondary encrypted API to get the IP address(s) of the DoH server's domain. +โœ… - If 2nd one fails, tries using Google's main encrypted API to get the IP address(s) of the DoH server's domain. +โœ… - If 3rd one fails, tries using Google's secondary encrypted API to get the IP address(s) of the DoH server's domain. + +โœ… All of the connections to Cloudflare and Google servers use direct IP, are set to use TLS 1.3 with TLS_CHACHA20_POLY1305_SHA256 cipher suite and use HTTP/2 + +More info about each of them in the GitHub repository +https://github.com/HotCakeX/WinSecureDNSMgr + + +"@ + + # Minimum version of the PowerShell engine required by this module + PowerShellVersion = '7.3.4' + + # Name of the PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # ClrVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() + + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + NestedModules = @('Set-BuiltInWinSecureDNS.psm1', 'Set-CustomWinSecureDNS.psm1', 'Set-DynamicIPDoHServer.psm1') + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @('Set-BuiltInWinSecureDNS', 'Set-CustomWinSecureDNS', 'Set-DynamicIPDoHServer') + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @('Set-BuiltInWinSecureDNS', 'Set-CustomWinSecureDNS', 'Set-DynamicIPDoHServer') + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @('Set-DOH', 'Set-CDOH', 'Set-DDOH') + + # DSC resources to export from this module + # DscResourcesToExport = @() + + # List of all modules packaged with this module + ModuleList = @() + + # List of all files packaged with this module + FileList = @( + 'WinSecureDNSMgr.psm1', + 'WinSecureDNSMgr.psd1', + 'Get-ActiveNetworkAdapterWinSecureDNS.psm1', + 'Get-ManualNetworkAdapterWinSecureDNS.psm1', + 'CommonResources.psm1', + 'Set-BuiltInWinSecureDNS.psm1', + 'Set-CustomWinSecureDNS.psm1', + 'Set-DynamicIPDoHServer.psm1' + ) + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('DNS', 'DNSoverHTTPS', 'DynamicDNSoverHTTPS', 'Windows11', 'SecureDNS', 'CloudFlare', 'CustomDNS', 'Security') + + # A URL to the license for this module. + LicenseUri = 'https://github.com/HotCakeX/WinSecureDNSMgr/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/HotCakeX/WinSecureDNSMgr' + + # A URL to an icon representing this module. + IconUri = 'https://raw.githubusercontent.com/HotCakeX/Windows-Secure-DNS-Config/main/PowerShellGalleryIcon.png' + + # ReleaseNotes of this module + ReleaseNotes = @" +# Version 0.0.3 +Simplified Set-CDOH function by automating a parameter, Streamlined the code, added custom colors to adapter selection area. + +# Version 0.0.2 +Added some successful messages to be displayed at the end of the execution + +# Version 0.0.1 +First release + +"@ + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + + # HelpInfo URI of this module + HelpInfoURI = 'https://github.com/HotCakeX/WinSecureDNSMgr' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' + +} diff --git a/WinSecureDNSMgr/WinSecureDNSMgr.psm1 b/WinSecureDNSMgr/WinSecureDNSMgr.psm1 new file mode 100644 index 0000000..c60959d --- /dev/null +++ b/WinSecureDNSMgr/WinSecureDNSMgr.psm1 @@ -0,0 +1,14 @@ +#Requires -RunAsAdministrator + +# Import sub-modules/functions into global scope that are required for main functions/cmdlets to operate +Import-Module -Name "$psscriptroot\Get-ActiveNetworkAdapterWinSecureDNS.psm1" -Force -Global +Import-Module -Name "$psscriptroot\Get-ManualNetworkAdapterWinSecureDNS.psm1" -Force -Global +Import-Module -Name "$psscriptroot\CommonResources.psm1" -Force -Global + +# Set PSReadline tab completion to complete menu for easier access to available parameters - Only for the current session +Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete + +# Stopping the module process if any error occurs +$ErrorActionPreference = 'Stop' + +# Everything in here applies to the entire module because this file is the root module and loads in the global scope by module manifest