Docs / Networking / Setting Up WireGuard VPN Between VPS Instances

Setting Up WireGuard VPN Between VPS Instances

By Admin · Apr 9, 2026 · Updated Apr 23, 2026 · 4 views · 3 min read

This guide covers how to set up and configure wireguard on a Linux VPS. Whether you're running a production environment or a development setup, these instructions will help you get started quickly and securely.

Prerequisites

  • Understanding of TCP/IP fundamentals
  • A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
  • A registered domain name (for public-facing services)
  • Access to server network configuration
  • Root or sudo access to the server

Network Configuration

Regular maintenance is essential for keeping your wireguard installation running smoothly. Schedule periodic reviews of log files, disk usage, and security updates to prevent issues before they occur.


# Network configuration and testing
ip addr show                   # View interfaces
ip route show                  # View routing table
ss -tlnp                       # View listening ports

# Firewall rules
sudo iptables -L -n -v         # List current rules
sudo ufw status verbose        # UFW status

The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.

Important Notes

The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.

Firewall Rules Setup

The vpn component plays a crucial role in the overall architecture. Understanding how it interacts with wireguard will help you make better configuration decisions.


# Configure network interface
sudo nano /etc/netplan/01-netcfg.yaml

network:
  version: 2
  ethernets:
    eth0:
      addresses:
        - 192.168.1.10/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 1.1.1.1

sudo netplan apply

This configuration provides a good balance between performance and resource usage. For high-traffic scenarios, you may need to increase the limits further.

Testing Connectivity

Before making changes to the configuration, always create a backup of the existing files. This ensures you can quickly roll back if something goes wrong during the setup process.


# Network configuration and testing
ip addr show                   # View interfaces
ip route show                  # View routing table
ss -tlnp                       # View listening ports

# Firewall rules
sudo iptables -L -n -v         # List current rules
sudo ufw status verbose        # UFW status

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

  • Keep all software components up to date
  • Use SSH keys instead of password authentication
  • Use strong, unique passwords for all services

Common Issues and Solutions

  • Connection timeout: Verify your firewall rules allow traffic on the required ports. Use ss -tlnp to confirm the service is listening on the expected port.
  • Slow performance: Check for disk I/O bottlenecks with iostat -x 1 and network issues with mtr. Review application logs for slow queries or requests.

Conclusion

This guide covered the essential steps for working with wireguard on a VPS environment. For more advanced configurations, refer to the official documentation. Don't hesitate to reach out to our support team if you need help with your specific setup.

Was this article helpful?