I just finished setting up my Wireguard VPN “server”. In this post I want to spread some information, I could’ve found useful but which didn’t come up in most of the Wireguard tutorials.

If you aren’t interested in VPN or self hosting, this post is not for you. If you haven’t gotten around yet to try it out, I can only recommend doing it. Feels great being able to “phone home” from all over the world.

Alright, tricks and tips:

tcpdump

Wireguard will definitely not work first try. As Wireguard is a silent protocol, you won’t see too many error messages. Dropped packets are how you know that something’s off. tcpdump is a great command line tool, that, despite it’s name, can also dump the precious UDP Wireguard packets. The tool will make you see how far your wireguard connection gets before the packets are dropped. Great for running on “server” and on clients.

ping

A classic tool. Helped me debugging some issues with DNS and Maximum Transfer Unit (MTU) size.

AllowedIPs

In a classic server-client situation, your clients should have AllowedIPs set to 0.0.0.0/0, ::/0 in their repecive configuration file. I found this pretty counterintuitive, but that seemingly is how it works.

IP Forwarding in sysctl

This one was by far the nastiest one to find out. Mainly because I’m not a linux or Debian expert. You need to tell sysctl to forward IP traffic, which ususally tutorials around the web will tell you to do like this: sysctl -w net.ipv4.ip_forward=1; sysctl -w net.ipv6.conf.all.forwarding=1. What I foolishly assumed, that this write operation was permanent. It’s not. You need to edit /etc/sysctl.conf for making it permanent. Else, after a reboot you won’t be able to connect to the internet. This took me a good amount of reconfigurations from scratch before I eventually found out these vars will reset on boot.

Maybe this helps some of you fellow Lemmings. If I stumble across further tips and tricks, I might update this post in the future. For now though, I think I’m done with my setup (philosophical question: are you ever done with setting up things?).

  • @MangoPenguin
    link
    English
    2826 days ago

    In a classic server-client situation, your clients should have AllowedIPs set to 0.0.0.0/0, ::/0 in their repecive configuration file.

    Only if you want the VPN to be your default route! Many may not want this.

  • @just_another_person@lemmy.world
    link
    fedilink
    21
    edit-2
    26 days ago

    Good lawd, these are the basic tenants of networking. I’m so sad people are unfamiliar. Let me throw a few more tricks your way:

    • telnet or netcat (nc on CLI): check if a port is listening and available
    • wget or curl: find out if an HTTP server is listening (or whatever, really)
    • netstat: kind of phased out on modern *nix distros, but useful for checking connections from hosts (you can still install it, but has been superceded by…)
    • ‘ss’ : same deal, different name
    • ‘ip route’: check your routing tables to make sure traffic goes where you think it should

    Check the docs, or search around for your particular usage, but these are all the barebones tools you need to figure out networking issues quickly.

  • 8adger
    link
    fedilink
    English
    1726 days ago

    The “allowed host” on the client side is to put the networks in you would like to route to. If you want to use the VPN tunnel for your default route it’s when you use the 0.0.0.0/0

  • @spaghettiwestern@sh.itjust.works
    link
    fedilink
    5
    edit-2
    25 days ago

    Another tip: On Android phones, Tasker can be used to automatically activate Wireguard tunnels to your own or a commercial VPN host. Taskernet.com has one project that activates WG when off specific wifi networks, and another that I wrote that allows you to activate a tunnel on demand only when you open specific apps. Great if you want to access a home server occasionally (without detectable open router ports) or want an extra layer of security when running a financial app.

  • I set up my server too, and other than the fields in the configuration and some iptables rules (I really should switch to nftables), it wasn’t a big hassle. Worked perfectly. But yes good tips about IP forwarding, I did it in the file directly but that can be a problem

  • @atzanteol@sh.itjust.works
    link
    fedilink
    English
    426 days ago

    “AllowedHosts” is the one thing that pisses me off the most. It’s a terrible name and caused me tons of confusion when first setting up wg.

  • @dino@discuss.tchncs.de
    link
    fedilink
    English
    324 days ago

    I mean…all this and much more is part of the wireguard archwiki. And whoever wants to setup a wireguard server but doesn’t know what ping is… Interesting would be an example on how to use tcpdump and how to read it.

  • Frater Mus
    link
    fedilink
    English
    325 days ago

    Wireguard self hosting

    I parsed this as Wireguard self-loathing and thought “that’s a little harsh”. :-)

  • 2xsaiko
    link
    fedilink
    226 days ago

    Another tip: take a look at systemd-networkd for managing your network connections! It has builtin support for creating wireguard tunnels and it’s very nice.