I don't have experience with OpenVPN, but, with a simple wireguard setup, you can have a single wireguard server which can allow access to any number of private subnets.
In this example, 10.xx.xx.x
are my private subnets, and 192.168.x.x
is my wireguard network.
- Pick or set up a dedicated machine as the wireguard server and set up a basic configuration. E.g. server side
[Interface]
Address = 192.168.200.1
PrivateKey = ...
ListenPort = 51820
[Peer] # Enes home computer
PublicKey = ...
AllowedIPs = 192.168.200.2
and client side
[Interface]
PrivateKey = ...
Address = 192.168.200.2
ListenPort = 51820
[Peer]
PublicKey = ...
Endpoint = your.wg.server
AllowedIPs = 192.168.200.1/32, 10.0.0.0/8 # We can route whatever we want!
- Configure the wireguard server to allow ip forwarding, with e.g. sysctl settings:
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1
- Configure the wireguard server to allow masquerading, e.g. with firewalld, a custom rule on the zone where the wireguard interface is (e.g. internal)
firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.211.0/24" masquerade' --permanent
firewall-cmd --reload
And that should be it. Use wg
to verify that wireguard is working and you should be able to ping any 10.x.x.x
address that the wireguard server can.
I run this setup with a single wireguard server VM against dozens of private subnets with hundreds of machines.