Last active
February 17, 2020 19:14
-
-
Save jamiehowarth0/ee2515d016e3cfc2dfa92afcd61693fc to your computer and use it in GitHub Desktop.
Turn on/off DHCP to re-route traffic via your router, instead of your Pi-Hole
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function PiOn() { | |
| $conn = Get-NetAdapter -physical | Where-Object Status -eq "Up" | |
| Set-DnsClientServerAddress -InterfaceIndex $conn.InterfaceIndex -ResetServerAddresses | |
| } | |
| function PiOff() { | |
| $conn = Get-NetAdapter -physical | Where-Object Status -eq "Up" | |
| $gateway = Get-NetIpConfiguration | Foreach IPv4DefaultGateway | Select-Object NextHop | |
| # This assumes the current gateway is your home router & your router still issues DHCP (instead of Pi-Hole). | |
| # If it's not, then uncomment the following line and specify your router's IP address. | |
| # ipAddress = 192.168.1.1 | |
| $ipAddress = $gateway.NextHop | |
| Set-DnsClientServerAddress -InterfaceIndex $conn.InterfaceIndex -ServerAddresses ( $ipAddress ) | |
| } | |
| Export-ModuleMember -Function PiOn, PiOff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment