19: Installing WireGuard - VPN Infrastructure
WireGuard is a modern,modern fast,VPN protocol using ChaCha20 encryption and secureCurve25519 key exchange. This installation uses WG-Easy (WireGuard-UI) for web-based client management, providing a user-friendly interface for VPN (Virtualadministration Privatewhile Network)maintaining thatWireGuard's lets you access your serverperformance and itssecurity services securely from anywhere. Once connected, you can access internal services, manage your server, and browse securely - all encrypted and protected!benefits.
For protocol specifications, advanced features, API documentation,configuration, and technical details,documentation, see the official WireGuard documentation.
Why WireGuard?
✅Secure access- Access your server and services securely from anywhere✅Easy to use- Web interface makes managing clients simple✅Fast and modern- Uses modern encryption (ChaCha20) for speed and security✅Mobile-friendly- QR codes for easy mobile device setup✅Multiple devices- Connect phones, laptops, tablets - all from one server✅Split tunneling- Only VPN traffic goes through VPN, rest uses normal internet✅Low overhead- Minimal impact on your internet speed
Prerequisites
- ✅ Docker
runninginstalled (fromChapter 3) - ✅ Docker Compose (Chapter 3)
- ✅ Linux kernel 5.6+ -
MostWireGuardmodernkernelLinuxmoduledistributions have thissupport - ✅ Optional: Traefik installed (
fromChapter 4) for HTTPSaccesswithaLet'sdomainEncrypt - ✅ Optional:
SubdomainDomain configured (fromChapter 4.5), e.g.,vpn.yourdomain.example.com - ✅ Firewall access - Ability to open UDP port
Installation via Infinity Tools
Menu Installation
📱 APPLICATIONS → WireGuard → Install
CLI Installation
sudo bash /opt/InfinityTools/Solutions/setup-wireguard.sh --install
# With domain (Traefik mode)
export WG_DOMAIN="vpn.example.com"
export WG_USE_TRAEFIK="true"
sudo -E bash /opt/InfinityTools/Solutions/setup-wireguard.sh --install
# Custom networks
export VPN_NETWORK_BASE="192.168.100"
export HOST_NETWORK_BASE="192.168.101"
export WG_VPN_PORT="51820"
sudo -E bash /opt/InfinityTools/Solutions/setup-wireguard.sh --install
Architecture
Containers
- wireguard - WG-Easy (WireGuard-UI) container (ngoduykhanh/wireguard-ui:latest)
- wireguard-https - Nginx SSL proxy (standalone HTTPS mode only)
Network Architecture
- VPN Network: Default
10.13.13.0/24(configurable)- WireGuard server:
10.13.13.1 - Admin client:
10.13.13.2 - Client IPs:
10.13.13.3+(auto-assigned)
- WireGuard server:
- Host Network: Default
10.13.14.0/24(configurable)- Host services IP:
10.13.14.1 - Accessible via VPN for host service access
- Host services IP:
Data Persistence
- Data:
/opt/speedbits/wireguard/data/(WG-Easy database, client configs) - Configs:
/opt/speedbits/wireguard/wg_confs/(WireGuard config files) - SSL:
/opt/speedbits/wireguard/ssl/(standalone mode certificates) - Password:
/opt/speedbits/wireguard/web-password.txt
Host Integration
- Kernel Module: WireGuard kernel module loaded on host
- Systemd Service:
wireguard-host-network.servicefor host network persistence - Network Interface:
wg-hostdummy interface for host network - iptables Rules: NAT and forwarding rules for VPN ↔ Host network
Deployment Modes
Traefik Mode
Uses Traefik for SSL termination and domain routing:
- Automatic Let's Encrypt certificate provisioning
- Domain-based access:
https://vpn.example.com - Security headers configured
- Requires: Traefik running, DNS A record configured
Standalone Mode (Default)
Direct access with HTTPS (self-signed):
- HTTPS:
https://SERVER_IP:8445(self-signed cert via nginx proxy) - Default web UI port: 8445 (configurable)
- VPN port: 51820 UDP (configurable)
- No domain required
Installation Process
Configuration Steps
- Network Configuration: VPN network base (default: 10.13.13) and Host network base (default: 10.13.14)
- DNS Configuration: Auto-detected from server's
/etc/resolv.conf - SSL Mode Selection: Choose Traefik or Standalone
- VPN Port: UDP port for VPN connections (default: 51820)
- Server
Endpoint:
Public IP or domain name for client connections Note:Kernel Module: WireGuardworkskernelgreatmodulewith Traefikinstalled anda domain name. Having a friendly URL likevpn.yourdomain.commakes it easy to access the web management interface.Step 1: Start Infinity Toolssudo infinity-toolsStep 2: Install WireGuardGo to📱 APPLICATIONSloadedSelectSystemdWireGuardService:ChooseHostInstallnetworkWireGuardservice created and enabled
UsingWhattheGetsInfinity Tools GUICreatedUse↑/↓Directory:to move,Enterto select,Escto go back/opt/speedbits/wireguardLook for theturquoise cursorContainers:indicatingwireguard,thewireguard-httpscurrent(standaloneselectionmode)EachDockerscreenCompose:shows/opt/speedbits/wireguard/docker-compose.yml- Systemd
shortService:description/etc/systemd/system/wireguard-host-network.service - Host
theScripts:tophost-network-setup.sh,explaininghost-network-cleanup.sh
aatwhat'sneededAccess Methods
Traefik Mode
https://vpn.example.comDirect web access after DNS propagation and SSL certificate generation (30-60 seconds).
Standalone Mode
https://SERVER_IP:8445Accept self-signed certificate warning (Advanced → Proceed).
Authentication
Web UI Credentials
- Username:
admin(fixed) - Password: Randomly generated (20 characters)
- Storage:
/opt/speedbits/wireguard/web-password.txt - Hash: bcrypt hash stored in container environment
StepVPN2.1:Client Authentication- Each client gets unique public/private key pair
- Server validates client public key
- No username/password required for VPN connection
- Keys generated cryptographically secure
Network Configuration
You'll be asked to configure two networks:
13.0/24)VPN Network (
Default:10.13.13)What it is:Purpose:The network used byWireGuard clients and Docker servicesWhatServeryou get:IP:Clients get IPs like10.13.13.3, 10.13.13.4, etc.Default:10.13.13 (usually fine to accept)Pick this if:You want the default setup (recommended)
Host Network (Default: 10.13.14)What it is:The network used for accessing host services (like Webmin, Apprise)What you get:Host services accessible at 10.13.14.1Default:10.13.14 (usually fine to accept)Pick this if:You want the default setup (recommended)
💡 Tip:Unless you have a specific reason, accept the defaults (just press Enter).Step 2.2: DNS ConfigurationWireGuard will automatically detect your server's DNS settings. This ensures VPN clients use the same DNS as your server for consistency.Usually, you can just accept the auto-detected DNS (press Enter).Step 2.3: Choose SSL ModeYou'll see two options. Here's what each means:Traefik (optional)What it is:Uses your domain name with a trusted HTTPS certificate from Let's EncryptWhat you need:A subdomain (e.g.,vpn.yourdomain.com) pointing to your server (see Chapter 4.5)What you get:Professional URL likehttps://vpn.yourdomain.comwith trusted SSLPick this if:You want secure, easy access with a domain name
Standalone (recommended)What it is:Uses HTTPS with a self-signed certificate and direct port accessWhat you need:Just a free port (default: 8445)What you get:URL likehttps://SERVER_IP:8445with a warning you must accept oncePick this if:You don't have a domain or prefer direct access (recommended)
Simple rule of thumb:UseStandalonefor most cases. UseTraefikif you have a domain and want trusted SSL.Step 2.4: VPN Port ConfigurationYou'll be asked for the UDP port for VPN connections:Default:51820What it is:The port clients will connect toImportant:You must open this port in your firewall!Pick this if:Default is fine (recommended)
Step 2.5: Server EndpointYou'll be asked for your server's public IP address or domain name:What it is:How clients will find your serverExamples:123.45.67.89orvpn.yourdomain.comImportant:ClientThis must be accessible from the internet!
What Happens During InstallationWireGuard kernel module is installed (if needed)WireGuard container is createdWeb management interface is set upRandom password is generated for web UIHost network interface is createdNetwork routing is configuredService starts and becomes accessible
Step 3: Open Firewall Port⚠️ CRITICAL:You MUST open the VPN port in your firewall, or clients cannot connect!Opening the Portsudo ufw allow 51820/udpReplace51820with your custom port if you chose a different one.Why This MattersWithout this, VPN clients cannot connect to your serverThe port must be UDP (not TCP)This is the ONLY port you need to open for VPN access
Step 4: Access WireGuard Web InterfaceIf Using TraefikWait 30-60 seconds for SSL certificate generationOpenhttps://vpn.yourdomain.comin your browserYou'll see the WireGuard login page
If Using StandaloneOpenhttps://SERVER_IP:8445in your browserYou'll see a security warning (normal for self-signed certificates)Click "Advanced" → "Proceed to site" to continueYou'll see the WireGuard login page
Step 5: Login to Web Interface⚠️ CRITICAL:During installation, a random password was generated and displayed. Save it immediately!Default CredentialsUsername:IPs:(auto-assigned)admin10.13.13.3+Password:Routing:Randomly generated (shown during installation)
If You Lost the PasswordYouClients canretrieve it from:cat /opt/speedbits/wireguard/web-password.txtLogin StepsEnter username:adminEnter the password shown during installationClick "Login"You'll see the WireGuard dashboard!
Step 6: Create Your First VPN ClientNow that you're logged in, let's create your first VPN client!Adding a ClientClick"Add Client"or the"+"buttonEnter a name for your device, e.g., "My Phone", "Laptop", "Work PC"Configure settings (or use defaults):Allowed IPs:Usually auto-filled (VPN network + Host network)Use Server DNS:Usually enabled (recommended)
Click"Save"or"Create"You'll see a QR code and download options!
What You'll Get📱QR Code- Scan with mobile devices📄Config File- Download for Windows/Linux🔑Client Details- IP address, public key, etc.
Step 7: Set Up WireGuard on Your DeviceWindowsInstall WireGuard from Microsoft StoreOpen WireGuard appClick"Add Tunnel"→"Import from file"Select the downloaded .conf fileClick"Activate"to connect
Android/iOSInstall WireGuard app from Play Store/App StoreOpen WireGuard appTap"+"→"Create from QR code"Scan the QR code from the web interfaceTap"Activate"to connect
LinuxInstall WireGuard:sudo apt install wireguardCopy the .conf file to:/etc/wireguard/wg0.confStart WireGuard:sudo wg-quick up wg0Enable auto-start:sudo systemctl enable wg-quick@wg0
Step 8: Understanding VPN NetworksWireGuard creates two networks for different purposes:VPN Network (10.13.13.0/24)This network is for WireGuard clients andaccess Dockerservices:📱Your devices- Get IPs like 10.13.13.3, 10.13.13.4, etc.🐳Docker services- Accessiblecontainers viatheircontainer names🌐Examples:Vaultwarden:http://vaultwarden:80WordPress:http://wordpress:80Apprise:http://apprise:8000
Host Network (10.13.14.0/24)
This- Purpose:
is for accessingAccess host services(servicesviarunning directly on the server):- VPN
🖥️HostservicesIP:- Accessible at10.13.14.1🌐Examples:Webmin:https://10.13.14.1:8443Apprise:http://10.13.14.1:8444SSH:ssh user@10.13.14.1
- Interface:
wg-hostdummy interface - Routing: NAT and forwarding rules configured
networkWhatiptables
YouRulesCan#AccessNATviafor VPN → Host network iptables -t nat -A POSTROUTING -s 10.13.13.0/24 -d 10.13.14.0/24 -j MASQUERADE # Forwarding rules iptables -A FORWARD -s 10.13.13.0/24 -d 10.13.14.0/24 -j ACCEPT iptables -A FORWARD -s 10.13.14.0/24 -d 10.13.13.0/24 -j ACCEPTEnvironment Variables
DockerWireGuardServices (VPN Network)ContainerAllWGUI_USERNAMEyour-InfinityWebToolsUIapplicationsusername (default: admin)AccessWGUI_PASSWORDvia-containerWebnamesUI password (randomly generated)WGUI_SERVER_INTERFACE_ADDRESSES- Server IP/CIDR (e.g.,http://vaultwarden:80)10.13.13.1/24)NoWGUI_SERVER_LISTEN_PORTneed-toVPNexposeUDPportsportpublicly!(default: 51820)WGUI_DEFAULT_CLIENT_ALLOWED_IPS- Default allowed IPs for clientsWGUI_DEFAULT_CLIENT_USE_SERVER_DNS- Use server DNS (default: true)WGUI_MANAGE_START- Auto-start WireGuard (default: true)WGUI_MANAGE_RESTART- Auto-restart WireGuard (default: true)SESSION_SECRET- Session encryption key (randomly generated)
Client Management
Web UI Features
- Add/remove clients via web interface
- Generate QR codes for mobile devices
- Download .conf files for desktop clients
- Enable/disable clients individually
- View connection statistics
- Monitor traffic usage
HostClientServicesConfiguration(HostClients
Network)are created via web UI. Each client gets:WebminUnique(ifpublic/privateinstalled)key pairAppriseAuto-assigned(ifIPinstalled)addressSSHPre-configuredaccessAllowedIPs (VPN + Host networks)AnyServerotherendpointservicesandrunningpublicon the hostkey
Security
RecommendationsConfigurationEncryption
- Cipher: ChaCha20 (symmetric encryption)
- Key Exchange: Curve25519 (elliptic curve)
- Hash: BLAKE2s
- Handshake: Noise protocol framework
Access Security
- ✅
OpenTraefikonlymodeVPNusesportLet's-EncryptClose other public portsSSL (Webmin,production-ready) - ✅ Standalone HTTPS uses self-signed certificates (acceptable for internal use)
- ✅ Security headers configured (X-Frame-Options, CSP, etc.)
- ✅
Use strong password- The generatedRandom passwordisgenerationstrong,(20keep it safe!characters) - ✅ Unique keys per client
Apprise,Container Security
- Requires
NET_ADMINandSYS_MODULEcapabilities - IP forwarding enabled
- Kernel module access for WireGuard
- Host network access for routing
Firewall Configuration
Required Ports
StoreUDPpassword51820securely(or custom VPN port) -UseVPNa password managerconnections (VaultwardenMUSTrecommended!)be open)✅TCPLimit8445client(standaloneaccessmode) -OnlyWebcreateUIclients(optional,forcantrustedbedevicesclosed after VPN setup)✅TCPDisable443unused(Traefikclientsmode) -Turn off clients you're not using✅Keep WireGuard updated- Re-run install script periodically for updates⚠️Protect web interface- The webWeb UImanagesviaall VPN clients - keep it secure!Traefik
Firewall Best Practices
After#settingOpenupVPNWireGuard,portyou(REQUIRED)cansudocloseufw allow 51820/udp # Close other publicports:# Close Webmin public accessports (access via VPN instead) sudo ufw delete allow 8443 #Close Apprise public access (access via VPN instead)Webmin sudo ufw delete allow 8444 #Close WireGuard web UI public access (access via VPN instead)Apprise sudo ufw delete allow 8445 # WireGuard web UISystemd Service
Host Network Service
NowService:accesswireguard-host-network.serviceeverything- Creates
viawg-hostVPN!dummy interface - Configures host network IP (10.13.14.1)
- Sets up routing and iptables rules
- Persists across reboots
securelyService Management
# Check status systemctl status wireguard-host-network.service # Restart service sudo systemctl restart wireguard-host-network.service # View logs journalctl -u wireguard-host-network.serviceTroubleshooting
Can'tVPNConnectConnectionto VPNIssuesCheckVerify firewall:MakesudosureufwUDPstatusport| grep 51820(or your custom port) is open- Check server
endpoint:endpointVerify the IP/domain is correct and accessibleaccessibility CheckVerify clientconfig:configMake(AllowedIPs,sureendpoint,you're using the correct .conf filekeys)- Check WireGuard
status:Runlogs:docker logs wireguard - Test
seeUDPerrorsconnectivity:nc -u -v SERVER_IP 51820
toCan'tHostAccessNetworkWeb InterfaceIssuesTraefikCheckmode:systemdWaitservice:30-60systemctlsecondsstatusafter installation for SSL certificate generationwireguard-host-network.serviceStandaloneVerifymode:interface:Acceptiptheaddrself-signedshowcertificate warningwg-host- Check
container:routing:Runip route show | grep 10.13.14 - Verify iptables rules:
iptables -t nat -L -n -v
Web UI Issues
- Check container status:
docker ps | grep wireguardto see if it's running CheckView logs:Rundocker logs wireguardto see error messages
Can't Access Services via VPNCheck VPN connection:Make sure WireGuard is connected on your deviceCheck IP address:Verifyyou're using the correct IPs (10.13.13.x or 10.13.14.1)Check Allowed IPs:Make sure client config includes both VPN and Host networksCheck routing:Verify network routing is configured correctly
Lost Web UI PasswordView savedpassword:cat /opt/speedbits/wireguard/web-password.txtIfTestfileAPI:doesn'tcurlexist,-uyou'lladmin:PASSWORDneed to reinstall WireGuardhttp://localhost:5000/api/sessions
WhereProductionto Find WireGuard After InstallConsiderationsOnAccesstheMethod:finishUsescreen,TraefikInfinitymodeToolsforprintsproductionthe(trustedweb interface URL and passwordSSL)YouFirewall:canOpenalsoonlyseeVPNitport,inclose📊otherSTATUSpublic& HEALTH → STATUSportsCheck the installation directory:/opt/speedbits/wireguard- Password
savedManagement:in:/opt/speedbits/wireguard/web-password.txt Client configs:/opt/speedbits/wireguard/data/(managed via web UI)
Managing VPN ClientsAdding More ClientsSimply repeat Step 6 for each device you want to connect. Each device gets its own unique IP address.Disabling ClientsIn the web interface, you can disable clients without deleting them. This is useful if you temporarily don't want a device to connect.Viewing Connection StatsThe web interface shows connection statistics for each client, including data transferred and connection time.You're Ready!WireGuard is now installed and ready to use! Remember:🔥 Open the firewall port (UDP 51820) - critical for connections!🔐 Save yourStore web UI password securely📱ClientCreateManagement: Regularly review and disable unused clients- Monitoring: Monitor VPN connections and traffic
- Backup: Backup client configurations and keys
- Updates: Re-run install script periodically for updates
Integration with Infinity Tools
WireGuard complements Infinity Tools by providing:
- Secure remote access to all Infinity Tools applications
- Access to Docker services without exposing ports publicly
- Access to host services (Webmin, Apprise) securely
- Centralized VPN management via
theweb interface
Recommended Setup:
🔒Open only VPN port (UDP 51820) publicly- Close other public ports
and(Webmin,accessApprise,everythingetc.) - Access all services via VPN
🌐Use VPN network (10.13.13.x) for Docker services🖥️Use Host network (10.13.14.1) for host services
Advanced Configuration
Custom Networks
Configure custom network ranges:
export VPN_NETWORK_BASE="192.168.100" export HOST_NETWORK_BASE="192.168.101" sudo -E bash setup-wireguard.sh --installCustom VPN Port
export WG_VPN_PORT="51821" sudo -E bash setup-wireguard.sh --installCustom DNS
export VPN_DNS="8.8.8.8,8.8.4.4" sudo -E bash setup-wireguard.sh --installClient Configuration Export
Via Web UI
- Download .conf file for desktop clients
- Scan QR code for mobile clients
- View client details (IP, public key, etc.)
Via Command Line
# View admin client config sudo bash setup-wireguard.sh --show-config # Client configs stored in ls /opt/speedbits/wireguard/data/peer_*/peer.confNext
steps:StepsWireGuard is now operational. Use it to:
- Create VPN clients for all your
firstdevices - Access
setInfinityupTools applications securely - Access host services without exposing ports
- Manage clients via web interface
- Monitor VPN connections and traffic
client,For advanced features, protocol specifications, and development guides, refer to the official WireGuard
on your device, test the connection, and start accessing your services securely from anywhere!documentation.