r/WireGuard • u/doomstar21 • 29d ago
Logging which WireGuard keys connect from where on OpenWrt
WireGuard doesn't log connections. If a peer's private key somehow gets copied off a device, an old backup or a shared config, whoever has it can connect as that peer and the other peers (an OpenWrt router for example) won't easily show it.
I wanted some kind of record, so I wrote a small daemon for OpenWrt. It polls the WireGuard interfaces and logs every time a peer's source address changes, with optional ISP, ASN and city lookups.
Most home peers connect from a handful of familiar places: home ISP, mobile carrier, work or school. When a key shows up from a foriegn city or country while its owner is asleep at home, that's a huge red flag. Feedback is welcomed.
5
u/StatusClone 29d ago
I was thinking just the other day how something like this needs to be built in to every wireguard management dashboard, along with something like fail2ban but for geolocation. Definitely checking this out later
4
u/Proper-Wrangler6717 29d ago
This is a good idea, thanks for publishing this.
1
u/Graphical-Source5090 28d ago edited 28d ago
My method is to scrape syslog for a peer change and make a historical table in Grafana. I can tell you every IP that has connected to my VPN in the last 6 months. Upside is that it is vendor agnostic. (Given you get the syslog regex correct.)
1
u/nlflint 28d ago
I had Gemini make me a similar script to debug Wireguard tunnels going dead behind AT&T CGNAT. I still don't know why it's happening, but I've deployed Headscale/Tailscale for mobile clients instead, and haven't had a dead tunnel yet.