WireGuard Site-to-Site VPN on Ubuntu 22.04 (Split Tunneling)
Connect Windows office networks with WireGuard on an Ubuntu 22.04 VPS. Step-by-step site-to-site setup with split tunneling to route only inter-office traffic.
What’s the best VPN/server solution to connect two Windows office networks into a single LAN using a VPS running Ubuntu 22.04, while configuring split tunneling (partial traffic forwarding) so only internal inter-office traffic goes through the tunnel? The VPS and offices are in the same city (no traffic masking required). Which software do you recommend (e.g., WireGuard, OpenVPN, IPsec, SoftEther) and where can I find step-by-step guides for setting up the Ubuntu server and configuring Windows clients for site-to-site / routed LAN-to-LAN partial routing?
WireGuard stands out as the best VPN solution for connecting two Windows office networks into a site-to-site VPN using an Ubuntu 22.04 VPS, thanks to its blazing speed, simplicity, and native split tunneling support that routes only inter-office traffic through the tunnel. You’ll set up the VPS as a central WireGuard server, configure each office’s Windows machine as a peer with specific AllowedIPs for partial traffic forwarding, keeping local internet direct. Step-by-step guides from DigitalOcean handle the Ubuntu server side perfectly, while Windows clients use the official WireGuard app for easy LAN-to-LAN routing.
Contents
- Why WireGuard Wins for Site-to-Site VPN
- Prerequisites and Network Planning
- Setting Up WireGuard Server on Ubuntu 22.04 VPS
- Configuring Split Tunneling for Partial Routing
- Windows Client Setup for Office Networks
- Alternatives: OpenVPN, IPsec, and SoftEther
- Troubleshooting Tips
Sources
- WireGuard Official Website
- DigitalOcean: WireGuard VPN Server on Ubuntu 22.04
- OpenVPN Official Website
- DigitalOcean: OpenVPN Server on Ubuntu 22.04
- SoftEther VPN Official Website
- Server World: SoftEther VPN on Ubuntu 22.04
- Microsoft Docs: VPN Split Tunneling
- Server World: SoftEther Client on Windows
- Server World: L2TP/IPsec Client on Windows
Conclusion
WireGuard delivers the simplest, fastest site-to-site VPN for your Ubuntu 22.04 VPS to bridge Windows office LANs with split tunneling—minimal config, maximum performance. Skip the complexity of OpenVPN or SoftEther unless you need extras like multi-protocol support. Test the tunnel with pings between offices, tweak AllowedIPs for precise routing, and you’re set for seamless inter-office access without bogging down everyday browsing.
Why WireGuard Wins for Site-to-Site VPN
Picture this: two offices in the same city, each with Windows machines on local LANs (say, 192.168.1.0/24 and 192.168.2.0/24). You want them chatting like one big network via a VPS, but only shove inter-office packets through the VPN tunnel—everything else hits the internet directly. That’s split tunneling in action, and WireGuard nails it.
Why not others first? OpenVPN’s flexible but config-heavy with certificates. IPsec (like L2TP/IPsec) works natively on Windows but drags on speed and setup. SoftEther’s a multi-tool powerhouse supporting everything, yet overkill here. WireGuard? It’s lean—just 4,000 lines of code, audited crypto, and UDP-based for low latency. Benchmarks show it crushing OpenVPN by 3-4x in throughput, perfect since no traffic masking’s needed locally.
And setup? Dead simple peer model: VPS as hub, offices as spokes. No users/passwords—just public keys.
Prerequisites and Network Planning
Before diving in, map your networks. Assume:
- Office A: LAN 192.168.1.0/24, public IP or dynamic DNS for client.
- Office B: LAN 192.168.2.0/24.
- VPS: Ubuntu 22.04, static public IP (e.g., 203.0.113.1), assign VPN subnet like 10.0.0.0/24.
You’ll need:
- Root access on VPS.
- Windows 10/11 machines in offices with admin rights.
- Firewall tweaks: Open UDP 51820 (default WireGuard port).
Pro tip: Pick non-overlapping LAN subnets. If they clash, renumber one office first—saves headaches.
Setting Up WireGuard Server on Ubuntu 22.04 VPS
Fire up your VPS and follow this—straight from DigitalOcean’s spot-on guide.
- Update and install:
sudo apt update && sudo apt install wireguard -y
- Generate keys:
wg genkey | tee server_private.key | wg pubkey > server_public.key
- Create
/etc/wireguard/wg0.conf:
[Interface]
Address = 10.0.0.1/24
PrivateKey = <server_private.key contents>
ListenPort = 51820
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
Enable forwarding: echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf && sysctl -p.
- For each office peer (generate client keys similarly):
[Peer] # Office A
PublicKey = <officeA_public.key>
AllowedIPs = 10.0.0.2/32, 192.168.1.0/24 # VPN IP + LAN
[Peer] # Office B
PublicKey = <officeB_public.key>
AllowedIPs = 10.0.0.3/32, 192.168.2.0/24
- Start it:
wg-quick up wg0 && systemctl enable wg-quick@wg0.
UFW firewall? sudo ufw allow 51820/udp. Boom—server’s live.
Configuring Split Tunneling for Partial Routing
Here’s the magic: AllowedIPs controls routing. On the server, listing office LANs (192.168.1.0/24, etc.) tells it to forward only that traffic between peers.
On clients (next section), mirror it: Office A config AllowedIPs = 10.0.0.0/24, 192.168.2.0/24 (VPS subnet + Office B LAN). Local traffic? Skips the tunnel entirely, per Microsoft’s split tunneling docs. No more hogging bandwidth for YouTube.
Want finer control? Add DNS or specific subnets. Test with ip route post-connect—should show routes only for remote LANs via wg0.
Windows Client Setup for Office Networks
Download WireGuard for Windows—MSI installer, no fuss.
-
Generate client keys on VPS or locally:
wg genkey | tee client_private.key | wg pubkey > client_public.key. Add public to server conf, restart wg0. -
Client conf (officeA.conf):
[Interface]
PrivateKey = <officeA_private>
Address = 10.0.0.2/24
DNS = 8.8.8.8 # Or your internal
[Peer]
PublicKey = <server_public>
Endpoint = vps.public.ip:51820
AllowedIPs = 10.0.0.0/24, 192.168.2.0/24 # Only inter-office + VPN
PersistentKeepalive = 25 # NAT traversal
- Import into WireGuard app, activate. Ping the other office’s gateway. Done—LAN-to-LAN site-to-site VPN.
For dynamic office IPs, use DDNS in Endpoint.
Alternatives: OpenVPN, IPsec, and SoftEther
WireGuard’s my pick, but here’s the rundown.
OpenVPN: Rock-solid, Ubuntu setup via DigitalOcean. Uses certs, push “route 192.168.2.0 255.255.255.0” for split. Windows OpenVPN GUI client. Slower, more steps.
IPsec/L2TP: Native Windows support—no extra software. But server-side? StrongSwan on Ubuntu, tricky. Split via route pushes. Server World L2TP guide for clients.
SoftEther: Swiss Army knife—L2TP/IPsec, OpenVPN emulation. Ubuntu install, Windows client. Great if mixing protocols, but steeper curve.
WireGuard edges them on speed/simplicity for your use.
Troubleshooting Tips
Tunnel up but no LAN access? Check:
- Routes:
ip routeon Linux,route printon Windows. - Firewalls: Windows Defender? Exclude WireGuard. Office routers block UDP?
- Keys mismatch? Regenerate.
- MTU issues? Add
MTU = 1420to confs.
wg show on server shows handshakes. Still stuck? Logs via journalctl -u wg-quick@wg0. Common fix: Ensure PostUp iptables persist across reboots.
Why WireGuard Wins for Site-to-Site VPN
Wait, I already have this. No, the structure has Sources before Conclusion, but in the example, Sources then — Conclusion. In my draft, I put Sources early by mistake? No, look at instructions:
After main sections, — before Sources, — before Conclusion.
In my response, I put Sources after Contents? No!
Correct order:
Brief
Contents
First H2
Next H2s with — between
Then after last H2 —
Sources
Conclusion
Yes, I misplaced Sources in thinking. In the response above, I have Contents — Sources — Conclusion — Why… that’s wrong.
I need to fix: Contents — first section — sections — — Sources — — Conclusion.
No more sections after Conclusion.
Also, TOC should list actual sections: Why, Prereq, Server, Split, Windows, Alt, Troubleshoot, then Sources, Conclusion.
Add those to TOC.
Sources after all main content.
Personality: Added questions, contractions, pro tips, varied sentences.
Links: Natural inline.
Keywords: site-to-site VPN, WireGuard Ubuntu 22.04, split tunneling, etc. in headings/first paras.
Good length.WireGuard is the top choice for a site-to-site VPN linking your two Windows office networks via an Ubuntu 22.04 VPS, delivering fast, simple setup with built-in split tunneling to route only inter-office LAN traffic through the tunnel. Configure the VPS as the central server, each office Windows machine as a peer with precise AllowedIPs for partial forwarding—local internet stays direct. Follow DigitalOcean’s Ubuntu WireGuard guide for server steps and the official WireGuard Windows app for clients, achieving routed LAN-to-LAN access in under an hour.
Contents
- Why Choose WireGuard for This Setup
- Network Planning and Prerequisites
- Install WireGuard Server on Ubuntu 22.04 VPS
- Enable Split Tunneling for Inter-Office Traffic
- Configure Windows Clients for Site-to-Site
- OpenVPN, IPsec, SoftEther Alternatives
- Common Issues and Fixes
Why Choose WireGuard for This Setup
You’ve got two Windows offices craving to act like one LAN, same-city VPS in between, and split tunneling to keep Netflix local. WireGuard crushes it—blazing fast per official specs, tiny codebase, modern crypto. No need for obfuscation, just pure routing efficiency.
OpenVPN? Config nightmare with certs. IPsec? Windows-native but sluggish. SoftEther? Overpowered multi-protocol beast. WireGuard’s peer model shines: VPS hub routes 192.168.1.0/24 ↔ 192.168.2.0/24, nothing else. Searches for “wireguard” (138k/mo) and “site to site vpn wireguard” prove it’s hot for a reason.
Network Planning and Prerequisites
First, sketch it out. Office A: 192.168.1.0/24 gateway at .1. Office B: 192.168.2.0/24 at .1. VPS gets VPN range 10.0.0.0/24 (server .1, A .2, B .3).
Grab:
- Ubuntu 22.04 VPS with public IP.
- Windows 10/11 in offices.
- Static LAN subnets—no overlaps!
Ports: UDP 51820 open. Dynamic office IPs? Use DDNS like noip.com. Ever hit subnet hell? Renumber early.
Install WireGuard Server on Ubuntu 22.04 VPS
Dive into DigitalOcean’s foolproof tutorial—it’s gold.
sudo apt update && sudo apt install wireguard -y
Keys:
wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.key
chmod 600 /etc/wireguard/server_*.key
/etc/wireguard/wg0.conf:
[Interface]
Address = 10.0.0.1/24
PrivateKey = <paste server_private.key>
ListenPort = 51820
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
# Later: peers here
IP forward: sysctl -w net.ipv4.ip_forward=1 (persist in /etc/sysctl.conf).
wg-quick up wg0 && systemctl enable --now wg-quick@wg0
UFW: ufw allow 51820/udp && ufw reload. Server ready.
Enable Split Tunneling for Inter-Office Traffic
Split tunneling shines here—Microsoft explains it nails performance. AllowedIPs = your route map.
Server peers (add to wg0.conf, wg-quick down/up):
[Peer] # Office A
PublicKey = <A_pubkey>
AllowedIPs = 10.0.0.2/32, 192.168.1.0/24
[Peer] # Office B
PublicKey = <B_pubkey>
AllowedIPs = 10.0.0.3/32, 192.168.2.0/24
Clients reverse it: A allows B’s LAN + VPN subnet. Only pings to 192.168.2.x tunnel; google.com skips. Pure. Efficient.
Configure Windows Clients for Site-to-Site
Snag WireGuard MSI for Windows. Generate keys locally or VPS-side, exchange publics.
Office A conf:
[Interface]
PrivateKey = <A_private>
Address = 10.0.0.2/24
[Peer]
PublicKey = <server_pub>
AllowedIPs = 10.0.0.0/24, 192.168.2.0/24
Endpoint = <vps_ip>:51820
PersistentKeepalive = 25
Import .conf in app → Tunnel → Activate. ipconfig shows wg0 routes. Ping B’s machines. Site-to-site magic.
Repeat for B, swap LANs in AllowedIPs. Router firewall? Punch UDP 51820.
OpenVPN, IPsec, SoftEther Alternatives
WireGuard’s king, but options:
OpenVPN: Flexible site-to-site. Ubuntu server guide, push routes for split (“iroute 192.168.2.0 255.255.255.0”). Windows GUI client. Verbose configs.
IPsec/L2TP: Zero-client-install on Windows. StrongSwan server, but crypto-heavy. Native Windows connect. Split via no “use default gateway”.
SoftEther: All-in-one. Ubuntu server, Windows client. Emulates L2TP/OpenVPN, split easy. If future-proofing.
Stick WireGuard unless protocol mixing.
Common Issues and Fixes
No handshake? wg show—check endpoints/keys. iptables vanish on reboot? Use nftables or persist script.
LAN unreachable? Verify routes (tracert), disable Windows firewall temporarily. MTU blackhole? MTU=1380 in conf.
Dynamic IP drops? Keepalive=25 + DDNS. Logs: Resolve DNS first? Journalctl -f -u wg-quick@wg0.
Test end-to-end: shared folder access. Smooth sailing 90% of time.