Last active
September 5, 2019 01:51
-
-
Save ncruces/7043ad10712e983cee73be27320fdf2c to your computer and use it in GitHub Desktop.
Whitelist Cloudflare's IP addresses in a Windows Firewall rule
This file contains 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
param( | |
[Parameter(Mandatory=$true)] | |
[String]$rule | |
) | |
$ipv4 = (Invoke-WebRequest -UseBasicParsing -Uri "https://www.cloudflare.com/ips-v4").Content | |
$ipv6 = (Invoke-WebRequest -UseBasicParsing -Uri "https://www.cloudflare.com/ips-v6").Content | |
$ips = ($ipv4 + $ipv6).TrimEnd().Split([Environment]::NewLine) | |
Set-NetFirewallRule -DisplayName $rule -RemoteAddress $ips |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment