40 lines
1.4 KiB
PowerShell
40 lines
1.4 KiB
PowerShell
# PowerShell script to update BGP prefixes
|
|
# BGP Prefixes Update Script
|
|
|
|
param(
|
|
[string]$PrefixesFile = "prefixes.txt"
|
|
)
|
|
|
|
Write-Host "Updating BGP Prefixes..." -ForegroundColor Cyan
|
|
|
|
# Check if container is running
|
|
$containerStatus = docker ps --filter "name=bgp-server" --format "{{.Names}}"
|
|
if (-not $containerStatus) {
|
|
Write-Host "Error: BGP container is not running. Please start it first." -ForegroundColor Red
|
|
Write-Host "Run: .\start-bgp-server.ps1" -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
|
|
# Check if prefixes file exists
|
|
if (-not (Test-Path $PrefixesFile)) {
|
|
Write-Host "Error: Prefixes file '$PrefixesFile' not found." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# Copy new prefixes file to container
|
|
Write-Host "Copying new prefixes file to container..." -ForegroundColor Yellow
|
|
docker cp $PrefixesFile bgp-server:/etc/frr/prefixes.txt
|
|
|
|
# Reload BGP configuration
|
|
Write-Host "Reloading BGP configuration..." -ForegroundColor Yellow
|
|
docker exec bgp-server vtysh -c "configure terminal" -c "router bgp 65000" -c "clear ip bgp *" -c "end"
|
|
|
|
# Wait a moment for BGP to stabilize
|
|
Start-Sleep -Seconds 3
|
|
|
|
# Show updated BGP table
|
|
Write-Host "`nUpdated BGP table:" -ForegroundColor Green
|
|
docker exec bgp-server vtysh -c "show ip bgp"
|
|
|
|
Write-Host "`nPrefixes updated successfully!" -ForegroundColor Green
|
|
Write-Host "To view current prefixes: docker exec -it bgp-server vtysh -c 'show ip bgp'" -ForegroundColor Yellow |