this post was submitted on 26 Nov 2023
2 points (100.0% liked)

Self-Hosted Main

515 readers
1 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

For Example

We welcome posts that include suggestions for good self-hosted alternatives to popular online services, how they are better, or how they give back control of your data. Also include hints and tips for less technical readers.

Useful Lists

founded 1 year ago
MODERATORS
 

Hi, when I am at home I don't need Wireguard, while when I go out of the house I would like it to turn on.

In summary by passing the mac address of my iPhone to the script, it is checked if it is present in the ARP table and if it is connected to the LAN by scanning with nmap. If I don't find it connected, I starto Wireguard. If it is connected, however, I turn it off.

I was planning to schedule it with crontab every 15 minutes.

Do you see any potential security issues with that? Could it be done better?

network=192.168.1.0/24
if [ “$#” -ne 1 ]; then echo Usage example: $0 aa:bb:cc:dd:ee:ff; exit 2; fi;
nmap -sP -T4 $network >& /dev/null
ip=$(sudo arp -n | grep $1 | awk ‘ { print $1 }’)
ping $ip -n -q -c 2 -i 0.2 -w 1 >& /dev/null
if [ $? -eq 0 ]; then
   echo Device is online \($ip\)
   sudo wg-quick down wg0
   echo Wireguard killed
else
   echo Device is offline
   sudo wg-quick up wg0
   echo Wireguard started
   exit 1
fi;
you are viewing a single comment's thread
view the rest of the comments
[–] BunnyEruption@alien.top 2 points 11 months ago (1 children)

What's the point of this? If you don't think wireguard is secure enough to leave running 24/7 I'm not sure only running it some number of hours a day is going to be much more secure?

[–] subven1@alien.top 1 points 11 months ago

Some people turn off their router at night or when they leave home. Does it make sense? Not really. Can you still do it? Of course...