{"id":572,"date":"2026-07-22T03:52:14","date_gmt":"2026-07-22T03:52:14","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=572"},"modified":"2026-08-05T22:18:14","modified_gmt":"2026-08-05T22:18:14","slug":"wireguard-vpn-vps-secure-remote-access","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/","title":{"rendered":"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">WireGuard is a kernel-resident VPN tunnel: roughly 4,000 lines of code, built on the Noise protocol framework with ChaCha20-Poly1305 authenticated encryption. Because it runs inside the Linux kernel (since 5.6) instead of in userspace, it delivers near-native throughput \u2014 benchmarks routinely show WireGuard saturating a gigabit link while OpenVPN manages 30\u201350% of line rate on the same hardware.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">VPN throughput is single-threaded, so it depends heavily on your vCPU&#8217;s single-core speed. Check the CPU specs \u2014 <a href=\"https:\/\/virtualserversvps.com\/#providers\">see the full specs on our VPS comparison table<\/a> \u2014 before you commit to a budget plan with a weak core.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How WireGuard Compares to OpenVPN<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><\/th><th>WireGuard<\/th><th>OpenVPN<\/th><\/tr><\/thead><tbody><tr><td>Codebase<\/td><td>~4,000 lines<\/td><td>100,000+ lines<\/td><\/tr><tr><td>Crypto<\/td><td>ChaCha20-Poly1305 (kernel)<\/td><td>OpenSSL, AES-NI<\/td><\/tr><tr><td>Transport<\/td><td>UDP only<\/td><td>UDP or TCP<\/td><\/tr><tr><td>Handshake<\/td><td>Noise IK (1 round trip)<\/td><td>TLS-style, multi-round<\/td><\/tr><tr><td>Config<\/td><td>One [Peer] block<\/td><td>Certificates + CRL<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The table explains the practical differences: WireGuard&#8217;s fixed header and kernel data path cut both latency and CPU overhead, while OpenVPN&#8217;s TCP mode can compound packet loss with retransmission stalls. For a VPS acting as a remote-access gateway, WireGuard is the default choice in 2026.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are trade-offs worth knowing. WireGuard is connectionless \u2014 there is no built-in notion of a session, so roaming clients and IP changes are handled gracefully, but per-user authentication and revocation require either manual peer management or a wrapper like wg-easy. OpenVPN brings a mature ecosystem of user databases and certificates. For a single-admin VPS or a small team, WireGuard&#8217;s simplicity wins; the <code>wg<\/code> command line is the entire control plane.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing WireGuard on the VPS<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update && apt install -y wireguard\nmodprobe wireguard\nsysctl -w net.ipv4.ip_forward=1\necho \"net.ipv4.ip_forward=1\" >> \/etc\/sysctl.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu 24.04 ships the wireguard-tools package and the kernel module is included in the generic kernel, so no third-party repositories are needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Choose the tunnel subnet before you configure anything. 10.0.0.0\/24 is the conventional choice, but if your LAN or office network already uses that range, pick 10.200.0.0\/24 or 172.16.0.0\/24 to avoid route collisions when clients are at home. Document the subnet and the server address \u2014 you will need them in every client config.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Generating Keys and Writing wg0.conf<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>umask 077\nwg genkey | tee \/etc\/wireguard\/privatekey | wg pubkey > \/etc\/wireguard\/publickey<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>[Interface]\nAddress = 10.0.0.1\/24\nListenPort = 51820\nPrivateKey = <server-private-key>\n\n[Peer]\nPublicKey = <client-public-key>\nAllowedIPs = 10.0.0.2\/32<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The server keeps a static address in the tunnel network (10.0.0.1\/24) and one <code>[Peer]<\/code> block per client, each with its own <code>\/32<\/code> address. Add more peers by appending blocks and restarting the interface.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Key hygiene matters more here than in most setups: the private key on the server should be readable only by root (<code>chmod 600 \/etc\/wireguard\/privatekey<\/code>), and the <code>wg0.conf<\/code> file should live in <code>\/etc\/wireguard\/<\/code> with the same permissions. If a client is compromised, remove its peer block \u2014 there is no certificate revocation list to update, which is both the simplicity and the risk of the protocol.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Enabling NAT for Client Traffic<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>iptables -t nat -A POSTROUTING -s 10.0.0.0\/24 -o eth0 -j MASQUERADE\nsystemctl enable --now wg-quick@wg0\nwg show   # verify handshakes appear<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The single MASQUERADE rule lets tunnel clients reach the internet through the VPS. Make it persistent with <code>iptables-persistent<\/code> or your firewall management tool so a reboot does not silently break the tunnel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the VPS also runs a firewall (ufw or nftables), allow UDP 51820 explicitly and ensure the FORWARD chain permits traffic between the tunnel interface and the public interface. A common failure mode is a firewall that allows the handshake but drops forwarded packets, leaving you with a tunnel that connects and then stalls \u2014 check <code>iptables -L -v<\/code> counters to see where packets stop.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding Clients<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>[Interface]\nAddress = 10.0.0.2\/24\nPrivateKey = <client-private-key>\nDNS = 1.1.1.1\n\n[Peer]\nPublicKey = <server-public-key>\nEndpoint = your.vps.ip:51820\nAllowedIPs = 0.0.0.0\/0\nPersistentKeepalive = 25<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Generate each client keypair with <code>wg genkey<\/code>\/<code>wg pubkey<\/code> and paste the public key into the server config.<\/li><li>For phones, render the client config as a QR code with <code>qrencode -t ansiutf8 &lt; client.conf<\/code> and scan it in the WireGuard app.<\/li><li><code>PersistentKeepalive = 25<\/code> keeps NAT mappings alive on mobile networks and behind carrier-grade NAT.<\/li><li>Add clients with <code>wg set wg0 peer &lt;pubkey&gt; allowed-ips 10.0.0.x\/32<\/code> without restarting the interface.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Full Tunnel vs Split Tunnel<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Full tunnel (<code>AllowedIPs = 0.0.0.0\/0<\/code>): all client traffic routes through the VPS \u2014 maximum privacy, higher latency, uses your VPS bandwidth.<\/li><li>Split tunnel (<code>AllowedIPs = 10.0.0.0\/24<\/code>): only VPS-bound traffic goes through the tunnel; everything else uses the local connection \u2014 better for accessing a home network or internal services.<\/li><li>For remote administration, a split tunnel plus SSH on the VPS is the leanest setup and keeps the VPS bandwidth bill flat.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting Common Failures<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Symptom<\/th><th>Cause<\/th><th>Fix<\/th><\/tr><\/thead><tbody><tr><td>Handshake never completes<\/td><td>UDP 51820 blocked<\/td><td>Open the port in the firewall \/ provider panel<\/td><\/tr><tr><td>No internet through tunnel<\/td><td>Missing MASQUERADE rule<\/td><td>Re-add POSTROUTING rule and check ip_forward<\/td><\/tr><tr><td>Slow throughput<\/td><td>Single-core bottleneck<\/td><td>Choose a VPS with a fast single-core vCPU<\/td><\/tr><tr><td>DNS leaks<\/td><td>Resolver not pushed<\/td><td>Set DNS = in the client [Interface] block<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Start with a full-tunnel config for maximum privacy, then trim <code>AllowedIPs<\/code> once you trust the routing. When you pick the node for it, <a href=\"https:\/\/virtualserversvps.com\/#providers\">compare plans side by side on our comparison table<\/a> \u2014 a fast single-core vCPU is what WireGuard actually needs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Prefer a managed node so you never touch kernel modules or NAT rules yourself? Cloudways VPS plans ship preconfigured servers with root access and 24\/7 support. See <a href=\"https:\/\/cloudways.com\/en\/?id=2010927&amp;data1=virtualserversvps\" rel=\"noreferrer noopener sponsored\" target=\"_blank\">Cloudways plans and pricing<\/a> to spin up a WireGuard host in minutes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WireGuard is a kernel-resident VPN tunnel: roughly 4,000 lines of code, built on the Noise protocol framework with ChaCha20-Poly1305 authenticated encryption. Because it runs inside the Linux kernel (since 5.6)&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":13,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-572","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works\" \/>\n<meta property=\"og:description\" content=\"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-22T03:52:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-05T22:18:14+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/\",\"name\":\"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-07-22T03:52:14+00:00\",\"dateModified\":\"2026-08-05T22:18:14+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/","og_locale":"en_US","og_type":"article","og_title":"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works","og_description":"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works","og_url":"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-07-22T03:52:14+00:00","article_modified_time":"2026-08-05T22:18:14+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/","url":"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/","name":"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-07-22T03:52:14+00:00","dateModified":"2026-08-05T22:18:14+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/wireguard-vpn-vps-secure-remote-access\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"WireGuard on a VPS: Server Setup, Client Configs, and Routing That Works"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/572","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=572"}],"version-history":[{"count":2,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/572\/revisions"}],"predecessor-version":[{"id":804,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/572\/revisions\/804"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}