Wireguard-docs: Setup, usage, configuration, and a full example
github.com
github.com
I posted the link myself to my repo, 0 points 14 hours later someone else posts it: 260+ points
No hate towards you axiomdata316, thanks for posting it, I'm just childishly complaining about the unfairness of fake internet points :p
You can get a VPN running in an hour or less. Algo even supports wireguard.
I currently have two VPNs — Algo Wireguard & iVPN.
Anecdotally the wireguard VPN rocks— crazy fast in every way, including connection/disconnection.
Sometimes YouTube is slow.. I just hop on WG and it’s fast again. I’ve achieved faster downloads via WG than my bare internet connection (thanks Linode!)
However, some points to consider:
1. If you use a VPS to host your own VPN.. you don’t gain privacy. Usually your IP can (mostly) still identify you. And your VPS company will hold you accountable for your traffic eg DMCA.
2. OpenVPN never borks my resolv.conf but Wireguard often leaves my DNS resolution in a state of confusion.
I did the default Streisand install with all services, and disabled password based login on the box (keys only).
It seems Streisand has some issues updating some components according to their issues board and it seems like the maintainer might have abandoned it.
Next time I’ll probably use algo instead. I just need wireshark anyways ;)
But then I'm looking for a configuration that allows me to route all my traffic via home from wherever I am, not a solution that allows me to route my home traffic via a third party.
Wireguard sounds interesting, and I'm going to learn more about it, but I like where I am with StrongSwan and just being able to issue a new certificate for a new device, and run with it.
Checking the source... excerpt from src/tools/wg-quick/openbsd.bash:
set_dns() {
[[ ${#DNS[@]} -gt 0 ]] || return 0
# TODO: this is a horrible way of doing it. Has OpenBSD no resolvconf?
cmd cp /etc/resolv.conf "/etc/resolv.conf.wg-quick-backup.$INTERFACE"
cmd printf 'nameserver %s\n' "${DNS[@]}" > /etc/resolv.conf
}Unfortunately, the same can be said for your VPN provider, depending on the provider. They can (and more than one does) save your name, address, billing details, as well as your source IP, and which IP and source ports you appear as after VPN translation has occurred.
Even if they don't do this, traffic analysis by the underlying network provider can de-anonymise your VPN'd traffic from your original source traffic too, and it doesn't take a genius to do this either.
Can be edited for DNS/subnet config, generates .conf files as needed and also handles QR code generation for adding mobile devices. Pair this with a $5 DO droplet and you're all set.
- https://github.com/pirate/wireguard-docs#config-shortcuts
- https://github.com/pirate/wireguard-docs#How-WireGuard-Manag...
- https://github.com/pirate/wireguard-docs#Dynamic-IP-Allocati...
Sadly most Wireguard howtos don't cover ipv6.
The address is going to be static: I'm not aware of a way to simulate privacy extensions with Wireguard. A workaround is to assign ULAs and apply NAT.
------------------
[Interface] Address = 172.16.31.1/24 Address = 2001:__::1/64 PrivateKey = __ ListenPort = 443
[Peer] PublicKey = __ PresharedKey = __ AllowedIPs = 172.16.31.2/32, 2001:__::2/128
[Peer] PublicKey = __ PresharedKey = __ AllowedIPs = 172.16.31.3/32, 2001:__::3/128
[...]
------------------
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -A FORWARD -o %i -j ACCEPT PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -D FORWARD -o %i -j ACCEPT
------------------
[Interface] Address = 172.16.31.2/24 Address = 2001:__::2/64 PrivateKey = __ DNS = 172.16.31.1, 2001:__::1 [Peer] PublicKey = __ PresharedKey = __ AllowedIPs = 0.0.0.0/0, ::/0 Endpoint = <server_ip>:443 PersistentKeepalive = 25
------------------
This weekend I wrote a simple tool to manage a client/server-style Wireguard setup. It's a little less tedious than copying and pasting "wg genkey" and "wg pubkey" output as you're setting up new clients. It's not quite easy enough for someone to use without prior Wireguard setup knowledge, but if you've gotten your first client-server pair running, then you'll recognize where this tool fits into the rest of your workflow.
Hope it helps someone.
https://github.com/pirate/wireguard-docs/commit/faaf447868a5...
I don't follow, NAT traversal is integral to IKEv2 and pretty much "just works" [1]. Reconnecting after network downtime is not an issue either, with either on demand connection setup (auto=add) or pretty standard ifupdown scripts/networkmanager. I don't believe I had to restart my strongswan daemons in the past few months either...
I also disagree that config is 'brittle'. Quite to the contrary, I think strongswan with its exhaustive documentation and a complete test suite which provides configuration for every host in every scenario in the test suite is a great accomplishment and an incredibly useful resource [example: 2].
I think wireguard has a great niche to fill as OpenVPN replacement (which has a lot of issues) but some of its supposed benefits over ipsec are a bit overblown and a confluence of 'I couldn't be bothered to read the manual', failure to understand a difference between host-based and policy-based routing [3] and a pinch of hype-driven development.
[1] https://wiki.strongswan.org/projects/strongswan/wiki/NatTrav...
[2] https://www.strongswan.org/testing/testresults/ikev2/rw-cert...
[3] https://wiki.strongswan.org/projects/strongswan/wiki/Introdu...
Care to elaborate?
I (used to) run L2TP/IPSec and WireGuard on my Edgerouter 4, and both would give “acceptable” speeds (30-40 MBit on a 300/300 connection), but when recreating my firewall in PfSense, I went full IKEv2, and have not regretted it. With my SG-3100 I get ~100 MBit with IKEv2.
On thing I hated about WireGuard is the fact that all clients require configuration on the server.
I do still run it on one of my servers, as a client to Mullvad VPN, which in turn is used by a few docker containers. It could easily be replaced by IKEv2, but sadly most VPN providers only support OpenVPN and WireGuard, or have horrible speeds.
Yes. If connectivity to clients behind NAT is important and you don't want to waste effort creating a 'bounce off' server.
ZeroTier makes it really easy to setup a private VPN with minimal config. The real value add with it is the work that's done regarding hole punching and if you have a carrier grade NAT that is tough to get through, it will relay your traffic (albeit at a throttled speed) which can be a great time saver.
The other thing is their online 'Central' where you can add/remove devices, assign IP addresses, set flow rules and more. I really like their service and the best part of it compared to my WireGuard server is I don't have to worry about downtime due to some problem with my server.
But it seems it's only really useful with static IPs.
Say my "Server" is behind a DDns Hostname and i want to connect to it from my Phone.
So my problem is. I allow incoming from 0.0.0.0 but on my mobile the DDns Hostname gets compiled to a specific IP.
OpenVpn has no problem with this setup. Is it solvable with Wireguard?
wg-dynamic seems to tackle this but wasn't really ready last time i checked
[1] https://git.zx2c4.com/WireGuard/tree/contrib/examples/rereso...
[2] https://wiki.archlinux.org/index.php/WireGuard#Endpoint_with...
https://github.com/pirate/wireguard-docs#Dynamic-IP-Allocati...
I don't want to ask for hand-holding, but some more comprehensive and accessible documentation might help me troubleshoot it better.
[0] https://wiki.archlinux.org/index.php/WireGuard#Using_systemd...
If you can't even connect to services on the peer then first delete all iptables and nftables rules and try again.
[0] https://wiki.archlinux.org/index.php/WireGuard#Server
[1] https://wiki.archlinux.org/index.php/Nftables#Masquerading
Can recommend this setup to everyone, especially on devices with spotty connections like a phone.
* I'd include this research paper. It's the "first mechanised cryptographic proof of WG protocol" : https://hal.inria.fr/hal-02100345/document
Self-plug right here. There are a ton of bash scripts to install and configure WireGuard. Here's mine: https://github.com/SirToffski/WireGuard-Ligase/
It will configure server and clients independent of the OS it's running at. Steps to install WG are provided in the Wiki. On Ubuntu server with pre-installed WG, the quick setup option will make a ready to use server. You can quickly edit the variables to change things up.
Cheers!
If you're willing to think of it as a secure control plane where the cryptographic identities of peers are mapped to IP addresses, you can run other tried-and-tested but insecure tunnels over it.
I'm also making a simple program for myself and friend that is able to talk to hosting providers via API, spawn a vps and just installs prebuild image with Wireguard, Pihole and Cloudflared installed and configured + UI to add / remove clients.
What I cannot see explicitly mentioned anywhere, is a full example of how to set up a central wireguard server which routes client traffic from the VPN subnet out to the Internet.
Is this done automatically/implicitly? If so how? I don’t see enough commands to make this happen.
Am I just stupid? What am I missing?
I'll add an example to the docs as well.
The documentation is complete, but I think the most important topic is `AllowedIPs`. The rest is pretty standard and unsurprising (if you have any networking knowledge at all). I had written a bit about AllowedIPs when I switched to WG myself: https://try.popho.be/wg.html , with examples too.
There is nothing weird about it at all.
If you've used IPv6 you'll see the equivalent /128 for a single address.
On your (eth0) network interface you're specifying a network that your interface belongs to, its used to determine routing on that interface, if you give it a single /32, there is no "network" for it to route to.
WireGuard isn't using the CIDR notation in the address value for routing, it's using allowed-ips.
inet 192.168.101.12/24 brd 192.168.101.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.1.25/32 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.1.32/31 scope global eth0
valid_lft forever preferred_lft forever
Seems to work fine, added a /31 just for fun.Has the author not learnt from the past or does it actually need to be written in C for some reason?
The original implementation is a kernel module. You can find a bunch of (excellent) talks online by wireguard's author which all have a focus on security aspects and avoiding vulnerabilities. Besides, Go and Rust (3rd pty) implementations exist.
Correct. This is a discussion site after all.
> The original implementation is a kernel module
How does that make it safer if it's written in C? Of course no one likes to think they're writing vulnerable code...
The kernel uses various C macros and GCC extensions. Ensuring that a module written in another language was compatible, even given that it would need to be built outside the normal tree would make its maintenance within the kernel tree impossible.
In terms of being written in C++/Rust/whatever, as an external module that complies with the kernel ABI (not guaranteed between kernel releases), go for it.
But if you want to have your protocol/module in the standard kernel tree, C is your choice.
Even within a single release, the kernel ABI varies depending on several kernel configuration options (for instance, CONFIG_SMP).
I have a short post about it here:
The C version is still faster because it's a kernel module.
https://github.com/pirate/wireguard-docs#Other-WireGuard-Imp...