Commit 1a34c9e6 by César Galvis

feat: added script for wireguard install and setup

parent e0e33dc4
...@@ -36,6 +36,8 @@ Vagrant.configure("2") do |config| ...@@ -36,6 +36,8 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", path: "src/scripts/ps/ChocolateyInstall.ps1" config.vm.provision "shell", path: "src/scripts/ps/ChocolateyInstall.ps1"
## Install Chocolatey packages ## Install Chocolatey packages
config.vm.provision "shell", path: "src/scripts/ps/ChocolateyInstallPackages.ps1" config.vm.provision "shell", path: "src/scripts/ps/ChocolateyInstallPackages.ps1"
## Wireguard Install and setup
config.vm.provision "shell", path: "src/scripts/ps/WireguardSetup.ps1"
## Change timezone ## Change timezone
config.vm.provision "shell", inline: <<-SHELL config.vm.provision "shell", inline: <<-SHELL
Write-Output "=== Change timezone ===" Write-Output "=== Change timezone ==="
......
choco install forticlientvpn --yes choco install forticlientvpn --yes
choco install squid --yes \ No newline at end of file
\ No newline at end of file
# Wireguard setup
# install-wireguard.ps1
# Define download URL for WireGuard official MSI installer
$wgInstallerUrl = "https://download.wireguard.com/windows-client/wireguard-installer.exe"
$installerPath = "$env:TEMP\wireguard-installer.exe"
# Download the installer
Write-Host "Downloading WireGuard from official site..."
Invoke-WebRequest -Uri $wgInstallerUrl -OutFile $installerPath
# Run the installer silently
Write-Host "Installing WireGuard..."
Start-Process -FilePath $installerPath -ArgumentList "/install /quiet" -Wait
# Wait for the installation to complete
Start-Sleep -Seconds 10
# Set paths
$wgPath = "C:\Program Files\WireGuard"
$configPath = "$wgPath\Configurations"
$serverConfigFile = "$configPath\server.conf"
$outputPath = "C:\vagrant\files\wireguard\Configurations"
# Create configuration and outpot folders if it doesn't exist
New-Item -ItemType Directory -Force -Path $configPath
New-Item -ItemType Directory -Force -Path $outputPath
# Generate server key pair
$serverPrivateKey = & "$wgPath\wg.exe" genkey
$serverPublicKey = $serverPrivateKey | & "$wgPath\wg.exe" pubkey
# Generate client key pair (you can extract and use this later)
$clientPrivateKey = & "$wgPath\wg.exe" genkey
$clientPublicKey = $clientPrivateKey | & "$wgPath\wg.exe" pubkey
# Save the keys for later (optional)
$keysOutput = @"
{
"Server Private Key": "$serverPrivateKey",
"Server Public Key": "$serverPublicKey",
"Client Private Key": "$clientPrivateKey",
"Client Public Key": "$clientPublicKey"
}
"@
$keysOutput | Out-File "$outputPath\generated-keys.json"
# Create the WireGuard server configuration
@"
[Interface]
PrivateKey = $serverPrivateKey
Address = 10.10.0.1/24
ListenPort = 51820
[Peer]
PublicKey = $clientPublicKey
AllowedIPs = 10.10.0.2/32
"@ | Out-File $serverConfigFile -Encoding ascii
# Install the tunnel as a Windows service
& "$wgPath\wireguard.exe" /installtunnelservice $serverConfigFile
# Optionally open the UDP port in Windows Firewall
New-NetFirewallRule -DisplayName "WireGuard VPN" -Direction Inbound -Action Allow `
-Protocol UDP -LocalPort 51820
# Output server info
Write-Host "WireGuard server has been configured and started."
Write-Host "Keys saved to: $outputPath\generated-keys.json"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment