Skip to content

Instantly share code, notes, and snippets.

@jamiehowarth0
Last active February 17, 2020 19:14
Show Gist options
  • Select an option

  • Save jamiehowarth0/ee2515d016e3cfc2dfa92afcd61693fc to your computer and use it in GitHub Desktop.

Select an option

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
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