Company VPN on your own server: WireGuard setup for staff access

One small Linux server with a public address and WireGuard is enough to let your staff reach private databases, admin panels and file shares while those systems stay closed to the internet. This page has a configuration you can copy, rules that give each person access only to what they need, and the routine for adding and removing people.

Updated: · Prices in the text are with the public IP (₼10 a month) unless stated otherwise.

What this VPN is for, and what it is not

It connects known people to systems that belong to your company: the accounting database, an internal CRM, RDP, a staging site. Traffic to those systems goes through the tunnel; everything else on the laptop keeps using the normal connection. This arrangement is called a split tunnel.

It is not a service for hiding where you are or getting around restrictions, and this guide does not cover that. Rules on VPN use and encryption differ by country, so check the law where your company and your staff are. The same goes for logging: employees should know that access is recorded.

The layout

PartExample addressOpen to the internet
VPN server, public interface eth0your public IPv4Yes, UDP 51820
VPN server, private interface eth110.20.0.2No
Database server10.20.0.5No
Staff laptops inside the tunnel10.66.0.11 and upNo

Servers ordered together here share a private subnet, so the VPN machine reaches the rest over their private addresses. Each of those servers also has its own public IPv4, so deny incoming traffic there in the firewall and bind its services to the private address. The private network guide shows how to split the tiers. Replace the addresses and interface names with yours: ip -br a lists interfaces, and ip route get 10.20.0.5 shows which one leads to the database.

Pick a tunnel range that no home router uses. Avoid 192.168.0.0/24 and 192.168.1.0/24, otherwise half of your staff will have an address conflict.

Set up the server

Ubuntu 24.04 or Debian 12, as root:

apt update && apt install -y wireguard ufw
umask 077
wg genkey | tee /etc/wireguard/server.key | wg pubkey > /etc/wireguard/server.pub
echo 'net.ipv4.ip_forward=1' > /etc/sysctl.d/99-vpn.conf
sysctl --system

Create /etc/wireguard/wg0.conf:

[Interface]
Address = 10.66.0.1/24
ListenPort = 51820
PrivateKey = SERVER_PRIVATE_KEY
# private servers see the traffic as coming from this machine
PostUp = iptables -t nat -A POSTROUTING -s 10.66.0.0/24 -d 10.20.0.0/24 -o eth1 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -s 10.66.0.0/24 -d 10.20.0.0/24 -o eth1 -j MASQUERADE

# Leyla, laptop
[Peer]
PublicKey = LEYLA_PUBLIC_KEY
AllowedIPs = 10.66.0.11/32

Open the port and start the tunnel. The SSH rule comes first, so you do not lock yourself out:

ufw allow OpenSSH
ufw allow 51820/udp
ufw enable
systemctl enable --now wg-quick@wg0
wg show

If the server is a private network VPS behind its own router, add a port forwarding rule for UDP 51820 to it.

Configure a laptop or phone

Install the official WireGuard app (Windows, macOS, Linux, Android, iOS), let it generate the key pair, and send only the public key to whoever runs the server. The client file:

[Interface]
PrivateKey = CLIENT_PRIVATE_KEY
Address = 10.66.0.11/32

[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = vpn.example.com:51820
AllowedIPs = 10.66.0.0/24, 10.20.0.0/24
PersistentKeepalive = 25

AllowedIPs lists only company networks, which makes the tunnel split. Use a DNS name as the endpoint, so moving the VPN later does not mean visiting every laptop.

Give each person only what they need

With ufw active, nothing is forwarded until you allow it. Grant access per address and port:

# Leyla: database only
ufw route allow in on wg0 out on eth1 proto tcp from 10.66.0.11 to 10.20.0.5 port 5432
# Administrator: everything in the private subnet
ufw route allow in on wg0 out on eth1 from 10.66.0.2 to 10.20.0.0/24

Once you have tested SSH through the tunnel, close the public SSH door too. Keep a session open while you do it; the browser console in the panel is your way back in if something goes wrong.

ufw allow in on wg0 to any port 22 proto tcp
ufw delete allow OpenSSH

Adding and removing people

Put the new [Peer] block into the file and apply it without dropping anyone (in bash):

wg syncconf wg0 <(wg-quick strip wg0)

Removing someone is the same: delete the block, run the command, delete the person's ufw rules. Do it on the last working day. Keep a table with name, device, tunnel address, public key and date. One key per device, never one per department, or you will not be able to revoke a lost phone.

A key file on a laptop is the whole login: WireGuard has no password or second factor. Require disk encryption, and keep a login on every system behind the VPN. Hardening the server itself is covered in the VPS security guide.

When it does not connect

  • No latest handshake in wg show: the port is closed, the endpoint is wrong or a public key is mixed up.
  • Handshake works, nothing opens: check forwarding (sysctl net.ipv4.ip_forward), the ufw route rule and the interface name.
  • Ping works, large pages hang: add MTU = 1380 to the client's [Interface].
  • Works from the phone, not from home: the home network uses the same range as your private subnet.

Size and cost

WireGuard is light. For 5 to 30 people using databases, remote desktop and web panels, Nano (1 vCPU, 1 GB RAM, 30 GB NVMe) is a reasonable starting point. It is ₼24.90 a month with the public IP the VPN needs, which is ₼10 of that. Take Basic (2 vCPU, 2 GB RAM, 40 GB NVMe) if the same machine also runs monitoring or a jump host. Heavy file transfer loads the CPU first, and there the second vCPU helps; watch top in the busiest hour.

  • Nano₼14.90/mo

    1 vCPU · 1 GB RAM · 30 GB NVMe

    Public IP +₼10/mo, With public IP: ₼24.90/mo

  • Basic₼27.90/mo

    2 vCPU · 2 GB RAM · 40 GB NVMe

    Public IP +₼10/mo, With public IP: ₼37.90/mo

Prices in manat (AZN), billed monthly. The public IP is +₼10 a month and is assigned automatically.

Company VPN questions

How many employees can one WireGuard server handle?

Dozens on a small plan if they use databases, RDP and web panels. The limit is traffic, not the number of keys, because an idle peer costs almost nothing.

Do I need a public IP address for a VPN server?

Yes, the VPN machine needs one so that laptops can find it, and it adds ₼10 a month to the server price. Servers behind it that only staff use need no open public port: deny everything incoming there. If they should have no public address at all, order them as a private network VPS.

WireGuard or OpenVPN for a company?

WireGuard is simpler and faster to run. Choose OpenVPN if you need logins from a directory, two-factor authentication or TCP on port 443 for networks that block UDP.

Can two offices be connected through one VPN server?

Yes. Give each office router a peer, add its local network to that peer's AllowedIPs on the server, and make sure the two offices use different address ranges.

Can Cloudraft engineers set the VPN up?

The server comes with full root access for you to configure. If you want it built and maintained, ask about DevOps as a Service.

Read next

All VPS pages

This page in other languages: Azərbaycanca · Русский

Servers in Baku, prices in manat

Create an account, top up your balance and order the plan you need.