a clean, expanded version of your script that supports four trading routes:
✅ London
✅ Singapore
✅ Frankfurt
✅ Hong Kong
You can now Allow one route and Block the other three, OR clear all rules.
If user selects 3, the script will:
Allow Frankfurt
Block London
Block Singapore
Block Hong Kong
Automatically resolves IPs every time → no stale firewall entries.
# ================================
# TRADING ROUTE MANAGER (ADMIN)
# 4–REGION VERSION
# ================================
# Define the target URLs and Regions
$LondonUrl = "edge-inet-ln-ext-prod-live-cc.trade.tt"
$SingaporeUrl = "edge-inet-sg-ext-prod-live-cc.trade.tt"
$FrankfurtUrl = "edge-inet-fr-ext-prod-live-cc.trade.tt"
$HongKongUrl = "edge-inet-hk-ext-prod-live-cc.trade.tt"
# Mapping of menu selections to URLs and names
$Regions = @{
"1" = @{ Name = "London"; Url = $LondonUrl }
"2" = @{ Name = "Singapore"; Url = $SingaporeUrl }
"3" = @{ Name = "Frankfurt"; Url = $FrankfurtUrl }
"4" = @{ Name = "Hong Kong"; Url = $HongKongUrl }
}
# Clear screen for better readability
Clear-Host
Write-Host "==========================================" -ForegroundColor Gray
Write-Host " TRADING ROUTE MANAGER (ADMIN) " -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Gray
Write-Host "1. ALLOW London"
Write-Host "2. ALLOW Singapore"
Write-Host "3. ALLOW Frankfurt"
Write-Host "4. ALLOW Hong Kong"
Write-Host "------------------------------------------"
Write-Host "5. REMOVE ALL RULES (Allow All)" -ForegroundColor Yellow
Write-Host "==========================================" -ForegroundColor Gray
$Choice = Read-Host "Select 1, 2, 3, 4, or 5"
# -----------------------------------------------------------
# OPTION 5 → REMOVE ALL ROUTES
# -----------------------------------------------------------
if ($Choice -eq "5") {
Write-Host "`nCleaning up ALL firewall rules..." -ForegroundColor Yellow
Remove-NetFirewallRule -DisplayName "RouteControl-Block" -ErrorAction SilentlyContinue
Remove-NetFirewallRule -DisplayName "RouteControl-Allow" -ErrorAction SilentlyContinue
ipconfig /flushdns | Out-Null
Write-Host "SUCCESS: All restrictions removed. All routes are now open." -ForegroundColor Green
exit
}
# Validate selection
if (-not $Regions.ContainsKey($Choice)) {
Write-Host "Invalid selection. Script aborted." -ForegroundColor Red
exit
}
# Determine allowed region
$AllowName = $Regions[$Choice].Name
$AllowUrl = $Regions[$Choice].Url
# Build list of ALL regions
$AllRegions = @(
@{ Name="London"; Url=$LondonUrl }
@{ Name="Singapore"; Url=$SingaporeUrl }
@{ Name="Frankfurt"; Url=$FrankfurtUrl }
@{ Name="Hong Kong"; Url=$HongKongUrl }
)
# Get list of regions to BLOCK (all except the one chosen)
$BlockRegions = $AllRegions | Where-Object { $_.Name -ne $AllowName }
# -----------------------------------------------------------
# DNS RESOLUTION
# -----------------------------------------------------------
Write-Host "`nResolving IP addresses..." -ForegroundColor Yellow
$AllowIPs = (Resolve-DnsName -Name $AllowUrl -ErrorAction SilentlyContinue).IPAddress
$BlockIPs = @()
foreach ($Region in $BlockRegions) {
$Resolved = (Resolve-DnsName -Name $Region.Url -ErrorAction SilentlyContinue).IPAddress
if ($Resolved) {
$BlockIPs += @{ Name = $Region.Name; IPs = $Resolved }
}
}
# -----------------------------------------------------------
# APPLY FIREWALL RULES
# -----------------------------------------------------------
# Remove previous rules
Remove-NetFirewallRule -DisplayName "RouteControl-Block" -ErrorAction SilentlyContinue
Remove-NetFirewallRule -DisplayName "RouteControl-Allow" -ErrorAction SilentlyContinue
# BLOCK ALL OTHER REGIONS
foreach ($Entry in $BlockIPs) {
New-NetFirewallRule -DisplayName "RouteControl-Block" `
-Direction Outbound -Action Block -RemoteAddress $Entry.IPs `
-Description "Blocked $($Entry.Name) Route"
Write-Host "[-] BLOCKED: $($Entry.Name) ($($Entry.IPs -join ', '))" -ForegroundColor Red
}
# ALLOW THE SELECTED REGION
if ($AllowIPs) {
New-NetFirewallRule -DisplayName "RouteControl-Allow" `
-Direction Outbound -Action Allow -RemoteAddress $AllowIPs `
-Description "Allowed $AllowName Route"
Write-Host "[+] ALLOWED: $AllowName ($($AllowIPs -join ', '))" -ForegroundColor Green
} else {
Write-Host "WARNING: Could not resolve IPs for $AllowName" -ForegroundColor Yellow
}
# -----------------------------------------------------------
# REFRESH NETWORK
# -----------------------------------------------------------
ipconfig /flushdns | Out-Null
Write-Host "`nSUCCESS: $AllowName route is now ACTIVE. Others BLOCKED." -ForegroundColor Cyan