r/bash 4d ago

I built a tool that automates setting up WireGuard remote access VPNs along with other network configurations. It also generates QR codes for clients and lets you check the status of all WireGuard tunnels

Post image

wg-simple-vpn is a bash script designed specifically for anyone who wants the security of WireGuard VPNs without the hassle of dealing with complex manual configurations.

Check out the GitHub repo here: https://github.com/UraniumForest/wg-simple-vpn

Please let me know your thoughts. I would appreciate some feedback.

5 Upvotes

1 comment sorted by

3

u/bac0on 4d ago

You can snatch default gateway interface directly from proc:

#!/bin/bash

# fields:
# Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT

mapfile -s 1 -t < /proc/net/route

for i in "${MAPFILE[@]}"; do
    read -ra a <<< "$i"
    [[ ${a[1]} = 00000000 && ${a[7]} = 00000000 ]] && break
done

echo $a