WireGuard
In WinBox you can configure WireGuard in WireGuard menu, or you can use terminal with command /interface wireguard
WireGuard uses public key cryptography instead of certificates, making it simpler to set up while maintaining high security.
Key concepts
WireGuard fundamentals
Key pairs:
Each device has a private key (kept secret) and public key (shared with peers)
Keys are used for authentication and encryption
Peers:
WireGuard connections are between "peers"
Each peer has an allowed IP range that defines which traffic it can send/receive
No traditional "server" or "client" - all devices are peers
Interface:
WireGuard creates a network interface (like
wg0)This interface has its own IP address within the VPN network
Server setup (RouterOS as WireGuard hub)
Generate server keys
First, create the WireGuard interface and generate key pair:
In WinBox go to WireGuard and click + to add new interface:
Name - wg-server (or your preferred name)
Listen Port - 13231 (default WireGuard port, can be customized)
Private Key - Click "Generate" to create new key pair
Configure server IP address
Assign an IP address to the WireGuard interface:
Add firewall rules
Allow WireGuard traffic through firewall:
Configure NAT (if needed)
If you want clients to access internet through the VPN:
Adding clients (peers)
Generate client keys
For each client, you need to generate a key pair. This is typically done on the client device, but you can generate them on RouterOS:
Add peer to server
In WinBox go to WireGuard -> Peers and click + to add peer:
Interface - wg-server
Public Key - Client's public key
Allowed Address - IP range client can use (e.g., 10.13.13.2/32)
Endpoint - Leave empty for dynamic clients
Persistent Keepalive - 25 (for NAT traversal)
Multiple clients example
Client configuration
Mobile client setup
For mobile devices, create a client configuration file:
Linux client setup
Windows client setup
Install WireGuard - Download from wireguard.com
Create tunnel - Import config file or create manually
Configure tunnel - Use the same configuration as above
Advanced configurations
Site-to-Site VPN
Connect two RouterOS devices with WireGuard:
Site A (Router 1):
Site B (Router 2):
Road warrior + Site-to-Site
Combine mobile clients with site-to-site connections:
Security and best practices
Key management
Generate keys securely - Use proper random number generation
Rotate keys regularly - Especially for long-term connections
Secure key storage - Protect private keys appropriately
Unique keys per peer - Never share keys between different peers
Network design
Use appropriate IP ranges - Avoid conflicts with existing networks
Implement firewall rules - Control traffic between peers if needed
Monitor connections - Track active peers and their usage
Plan for scalability - Consider IP address allocation for growth
Performance optimization
Troubleshooting
Common issues
Handshake failures:
Verify public keys are correct
Check firewall allows UDP traffic on WireGuard port
Ensure endpoint IP/port is reachable
No internet access:
Check NAT rules are configured
Verify AllowedIPs includes 0.0.0.0/0 on client
Test DNS resolution
Connection drops:
Enable persistent keepalive
Check NAT timeout settings
Verify network stability
Monitoring and diagnostics
Performance testing
Last updated
Was this helpful?