Created comprehensive VPN setup tooling for Peaceful Spirit L2TP/IPsec connection and enhanced agent documentation framework. VPN Configuration (PST-NW-VPN): - Setup-PST-L2TP-VPN.ps1: Automated L2TP/IPsec setup with split-tunnel and DNS - Connect-PST-VPN.ps1: Connection helper with PPP adapter detection, DNS (192.168.0.2), and route config (192.168.0.0/24) - Connect-PST-VPN-Standalone.ps1: Self-contained connection script for remote deployment - Fix-PST-VPN-Auth.ps1: Authentication troubleshooting for CHAP/MSChapv2 - Diagnose-VPN-Interface.ps1: Comprehensive VPN interface and routing diagnostic - Quick-Test-VPN.ps1: Fast connectivity verification (DNS/router/routes) - Add-PST-VPN-Route-Manual.ps1: Manual route configuration helper - vpn-connect.bat, vpn-disconnect.bat: Simple batch file shortcuts - OpenVPN config files (Windows-compatible, abandoned for L2TP) Key VPN Implementation Details: - L2TP creates PPP adapter with connection name as interface description - UniFi auto-configures DNS (192.168.0.2) but requires manual route to 192.168.0.0/24 - Split-tunnel enabled (only remote traffic through VPN) - All-user connection for pre-login auto-connect via scheduled task - Authentication: CHAP + MSChapv2 for UniFi compatibility Agent Documentation: - AGENT_QUICK_REFERENCE.md: Quick reference for all specialized agents - documentation-squire.md: Documentation and task management specialist agent - Updated all agent markdown files with standardized formatting Project Organization: - Moved conversation logs to dedicated directories (guru-connect-conversation-logs, guru-rmm-conversation-logs) - Cleaned up old session JSONL files from projects/msp-tools/ - Added guru-connect infrastructure (agent, dashboard, proto, scripts, .gitea workflows) - Added guru-rmm server components and deployment configs Technical Notes: - VPN IP pool: 192.168.4.x (client gets 192.168.4.6) - Remote network: 192.168.0.0/24 (router at 192.168.0.10) - PSK: rrClvnmUeXEFo90Ol+z7tfsAZHeSK6w7 - Credentials: pst-admin / 24Hearts$ Files: 15 VPN scripts, 2 agent docs, conversation log reorganization, guru-connect/guru-rmm infrastructure additions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
141 lines
5.0 KiB
PowerShell
141 lines
5.0 KiB
PowerShell
# Standalone VPN connection script - copy this to any machine
|
|
# No dependencies, includes everything needed
|
|
|
|
$vpnName = "PST-NW-VPN"
|
|
$username = "pst-admin"
|
|
$password = "24Hearts$"
|
|
$dnsServer = "192.168.0.2"
|
|
$remoteNetwork = "192.168.0.0"
|
|
$subnetMask = "255.255.255.0"
|
|
|
|
Write-Host "=== PST VPN Connection ===" -ForegroundColor Cyan
|
|
|
|
# Connect to VPN
|
|
Write-Host "`n[1/3] Connecting to $vpnName..." -ForegroundColor Yellow
|
|
$result = cmd /c "rasdial `"$vpnName`" $username $password" 2>&1
|
|
|
|
if ($LASTEXITCODE -ne 0 -and $result -notlike "*Already connected*") {
|
|
Write-Host "[ERROR] Connection failed: $result" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "[OK] Connected to VPN" -ForegroundColor Green
|
|
|
|
# Wait for interface to be ready
|
|
Start-Sleep -Seconds 5
|
|
|
|
# Find VPN interface
|
|
Write-Host "`n[2/3] Configuring DNS and routes..." -ForegroundColor Yellow
|
|
|
|
# Show all active interfaces for debugging
|
|
Write-Host "Active network interfaces:" -ForegroundColor Gray
|
|
Get-NetAdapter | Where-Object { $_.Status -eq "Up" } | ForEach-Object {
|
|
Write-Host " - $($_.Name): $($_.InterfaceDescription)" -ForegroundColor DarkGray
|
|
}
|
|
|
|
# Try to find VPN interface - L2TP creates a PPP adapter with the connection name
|
|
$vpnInterface = $null
|
|
|
|
# Method 1: Look for exact match on connection name (most reliable)
|
|
$vpnInterface = Get-NetAdapter | Where-Object {
|
|
($_.InterfaceAlias -eq $vpnName -or
|
|
$_.InterfaceDescription -eq $vpnName -or
|
|
$_.Name -eq $vpnName) -and
|
|
$_.Status -eq "Up"
|
|
} | Select-Object -First 1
|
|
|
|
if ($vpnInterface) {
|
|
Write-Host "Found VPN interface by connection name" -ForegroundColor Gray
|
|
}
|
|
|
|
# Method 2: Look for PPP adapter (L2TP uses PPP)
|
|
if (-not $vpnInterface) {
|
|
Write-Host "Trying PPP adapter pattern..." -ForegroundColor Gray
|
|
$vpnInterface = Get-NetAdapter | Where-Object {
|
|
$_.InterfaceDescription -like "*PPP*" -and $_.Status -eq "Up"
|
|
} | Select-Object -First 1
|
|
}
|
|
|
|
# Method 3: Look for WAN Miniport (fallback)
|
|
if (-not $vpnInterface) {
|
|
Write-Host "Trying WAN Miniport pattern..." -ForegroundColor Gray
|
|
$vpnInterface = Get-NetAdapter | Where-Object {
|
|
$_.InterfaceDescription -like "*WAN*" -and $_.Status -eq "Up"
|
|
} | Select-Object -First 1
|
|
}
|
|
|
|
if ($vpnInterface) {
|
|
Write-Host "Using interface: $($vpnInterface.Name) (Index: $($vpnInterface.InterfaceIndex))" -ForegroundColor Green
|
|
Write-Host " Description: $($vpnInterface.InterfaceDescription)" -ForegroundColor Gray
|
|
|
|
# Set DNS
|
|
try {
|
|
Set-DnsClientServerAddress -InterfaceIndex $vpnInterface.InterfaceIndex -ServerAddresses $dnsServer -ErrorAction Stop
|
|
Write-Host "[OK] DNS set to $dnsServer" -ForegroundColor Green
|
|
}
|
|
catch {
|
|
Write-Host "[WARNING] Could not set DNS: $_" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Add route
|
|
try {
|
|
Write-Host "Adding route for $remoteNetwork..." -ForegroundColor Gray
|
|
|
|
# Delete existing route
|
|
cmd /c "route delete $remoteNetwork" 2>&1 | Out-Null
|
|
|
|
# Add new route
|
|
$routeResult = cmd /c "route add $remoteNetwork mask $subnetMask 0.0.0.0 if $($vpnInterface.InterfaceIndex) metric 1" 2>&1
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "[OK] Route added for $remoteNetwork/24" -ForegroundColor Green
|
|
}
|
|
else {
|
|
Write-Host "[WARNING] Route add returned: $routeResult" -ForegroundColor Yellow
|
|
}
|
|
}
|
|
catch {
|
|
Write-Host "[WARNING] Could not add route: $_" -ForegroundColor Yellow
|
|
}
|
|
}
|
|
else {
|
|
Write-Host "[WARNING] Could not identify VPN interface!" -ForegroundColor Yellow
|
|
Write-Host "You may need to manually configure DNS and routes" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Verify connection
|
|
Write-Host "`n[3/3] Verification..." -ForegroundColor Yellow
|
|
|
|
# Check rasdial status
|
|
$connectionStatus = rasdial
|
|
Write-Host "Connection status:" -ForegroundColor Gray
|
|
Write-Host $connectionStatus -ForegroundColor DarkGray
|
|
|
|
# Check route
|
|
$routeCheck = route print | Select-String $remoteNetwork
|
|
if ($routeCheck) {
|
|
Write-Host "[OK] Route to $remoteNetwork exists" -ForegroundColor Green
|
|
}
|
|
else {
|
|
Write-Host "[WARNING] Route to $remoteNetwork not found in routing table" -ForegroundColor Yellow
|
|
}
|
|
|
|
# Test connectivity
|
|
Write-Host "`nTesting connectivity to $dnsServer..." -ForegroundColor Gray
|
|
$pingResult = Test-Connection -ComputerName $dnsServer -Count 2 -Quiet
|
|
|
|
if ($pingResult) {
|
|
Write-Host "[OK] Remote network is reachable!" -ForegroundColor Green
|
|
}
|
|
else {
|
|
Write-Host "[WARNING] Cannot ping $dnsServer" -ForegroundColor Yellow
|
|
Write-Host "This might be normal if ICMP is blocked" -ForegroundColor Gray
|
|
}
|
|
|
|
Write-Host "`n=== Connection Summary ===" -ForegroundColor Cyan
|
|
Write-Host "VPN: Connected" -ForegroundColor Green
|
|
Write-Host "DNS: Configured (if interface was found)" -ForegroundColor $(if ($vpnInterface) { "Green" } else { "Yellow" })
|
|
Write-Host "Route: Configured (if interface was found)" -ForegroundColor $(if ($vpnInterface) { "Green" } else { "Yellow" })
|
|
Write-Host "`nTo disconnect: rasdial `"$vpnName`" /disconnect" -ForegroundColor Gray
|
|
Write-Host ""
|