所以我們必須要自己開關 TCP Port 80,無法針對不特定驗證來源 IP 設定白名單
以下設定僅阻擋來自 Public IP 的請求,Pirvate IP 是允許連線的
開始更新憑證前: (開啟 Internet 可對 TCP Port 80 連線)
$BlockIPs = $BlockIPs = @("1.0.0.0-9.255.255.255", "11.0.0.0-172.15.255.255", "172.33.0.0-192.167.255.255", "192.169.0.0-255.255.255.255")第二行指令的用意在於若原本沒有 "TCP80BlockFromInternet" 這個 Firewall Rule Group 的話第三行會報錯,所以加上第一、第二行的宣告讓他先產生這個 Firewall Rule Group 再來移掉更新完憑證之後加入的阻擋規則
New-NetFirewallRule -DisplayName "RemovePrepare" -Group "TCP80BlockFromInternet" -Direction Inbound -Action Block -RemoteAddress $BlockIPs
Remove-NetFirewallRule -Group "TCP80BlockFromInternet" -Confirm:$False
更新完憑證之後: (阻擋 Internet 對 TCP Port 80 的連線)
$BlockIPs = $BlockIPs = @("1.0.0.0-9.255.255.255", "11.0.0.0-172.15.255.255", "172.33.0.0-192.167.255.255", "192.169.0.0-255.255.255.255")
New-NetFirewallRule -DisplayName "TCP80BlockFromInternet" -Group "TCP80BlockFromInternet" -Direction Inbound -LocalPort 80 -Protocol TCP -Action Block -RemoteAddress $BlockIPs
同場加映: (不指定 Protocol 與 Port, 全部阻擋的開關)
$BlockIPs = $BlockIPs = @("1.0.0.0-9.255.255.255", "11.0.0.0-172.15.255.255", "172.33.0.0-192.167.255.255", "192.169.0.0-255.255.255.255")
New-NetFirewallRule -DisplayName "RemovePrepare" -Group "Block Connection To Internet" -Direction Outbound -Action Block -RemoteAddress $BlockIPs
Remove-NetFirewallRule -Group "Block Connection To Internet" -Confirm:$False
$BlockIPs = $BlockIPs = @("1.0.0.0-9.255.255.255", "11.0.0.0-172.15.255.255", "172.33.0.0-192.167.255.255", "192.169.0.0-255.255.255.255")
New-NetFirewallRule -DisplayName "Block Connection To Internet" -Group "Block Connection To Internet" -Direction Outbound -Action Block -RemoteAddress $BlockIPs
沒有留言:
張貼留言