shield-keyholeWireGuard

circle-info

WireGuard is a modern VPN protocol that offers excellent performance, strong cryptography, and simpler configuration compared to OpenVPN.

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

  1. Install WireGuard - Download from wireguard.com

  2. Create tunnel - Import config file or create manually

  3. 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

  1. Generate keys securely - Use proper random number generation

  2. Rotate keys regularly - Especially for long-term connections

  3. Secure key storage - Protect private keys appropriately

  4. Unique keys per peer - Never share keys between different peers

Network design

  1. Use appropriate IP ranges - Avoid conflicts with existing networks

  2. Implement firewall rules - Control traffic between peers if needed

  3. Monitor connections - Track active peers and their usage

  4. Plan for scalability - Consider IP address allocation for growth

Performance optimization


chevron-rightShow complete WireGuard server setuphashtag

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?