Comments (1)
Problem seems to be solved on the current release as of 11/09/2019...
Wireguard is stateless, the VPN connection is meant to be kept when after sleep/hibernate but because network manager is disconnecting on sleep/hibernate we loose the stateless feature, i did make a special setup to get back this feature, this setup also work with other VPN system like OpenVPN, for info and if any one need this solution here is what i did:
Restoring VPN connection after sleep/hibernate (if it was used)
Features:
- Display current ip
- Warn on wan ip change
- Reconnect VPN if it was used before sleep
Setup:
- First under KDE i use a the widget "Command Output" and setup the widget to run "sh Ip.Vpn.Watcher.sh" every 15 sec (this watch for ip changes notify it, display current ip, and save current used network to
/tmp/used-conn
) - Systemd is configured to run a script after sleep/hibernate:
suspend-vpn
is added to/usr/lib/systemd/system-sleep/
suspend-vpn
triggerWait.Network.And.Restore.VPN.sh
That's it :)
**Ip.Vpn.Watcher.sh**
#!/bin/bash
wget -q http://internet.adress.that.return.myip.in.text/ip.php -O /tmp/ip --force-clobber
ip=$( cat /tmp/ip )
wantedip=$( cat /tmp/ip-old )
if [[ $ip = $wantedip ]]
then
echo $ip
nmcli --fields name connection show --active | tail -n +2 | head -n 1 > /tmp/used-conn
else
if [[ $ip != "" ]]
then
echo $ip
zenity --warning --title="VPN Watcher" --width=250 --text="\nWARNING : Wan IP Changed !"
nmcli --fields name connection show --active | tail -n +2 | head -n 1 > /tmp/used-conn
cp -f /tmp/ip /tmp/ip-old
else
echo $ip
zenity --warning --title="VPN Watcher" --width=250 --text="\nWARNING : Wan Connection Gone !"
cp -f /tmp/ip /tmp/ip-old
fi
fi
**suspend-vpn**
#!/bin/bash
# $1 values ('pre' or 'post')
# $2 values ('suspend', 'hibernate', or 'hybrid-sleep')
# case "$1/$2" in
case $1 in
pre)
# Save connection state
# Too late for this network is already gone...
# Implemented via check ip (plasmoid)
# nmcli --fields name connection show --active | tail -n +2 | head -n 1 > /tmp/used-conn
;;
post)
# Restore connection
su username -c "export DISPLAY=:0; export XDG_RUNTIME_DIR='/run/user/2000'; /scripts/location/Wait.Network.And.Restore.VPN.sh &"
;;
esac
**Wait.Network.And.Restore.VPN.sh**
#!/bin/bash
timer=1
conn=$( cat /tmp/used-conn )
printf "%s" "Waiting For Online State ..."
while ! ping -c 1 -n -w 1 8.8.8.8 &> /dev/null
do
printf "%c" "."
sleep 1
let "timer++"
if [[ ( $timer -ge 300 ) ]] ; then
printf "\n%s\n" "Script Timeout"
exit
fi
done
printf "\n%s\n" "Network Is Online"
if [[ $conn == VPNCONNECTIONAME* ]] || [[ $conn == VPNCONNECTIONAME2* ]]
then
# Need to wait network to be up
sleep 5
nmcli connection up $conn
fi
from network-manager-wireguard.
Related Issues (20)
- Endpoint parameter of form[ipv6]:port is not accepted
- configuration problem
- Won't build on Ubuntu 20.04 HOT 5
- Internet don't work after start wireguard HOT 1
- Does not appear in Fedora 35 HOT 2
- Complete and utter failure to autogen HOT 1
- resolvconf required on ubuntu
- Add build deb packages
- Add automatic connect on VPN Settings HOT 1
- Internet traffic not routed through VPN
- error when trying to connect: failed to look up VPN interface index HOT 4
- Cannot make
- AllowedIPs not working properly
- Stopped working with Ubuntu 22.04 HOT 18
- Cannot autoconf in Ubuntu 21.10 HOT 2
- Cannot activate VPN if IPv6 disabled in the Kernel
- Can't enable VPN connection in menu HOT 1
- Wireguard VPN didn't work through network manager HOT 1
- Move to GNOME GitLab HOT 1
- Issue with Makefile?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from network-manager-wireguard.