Skip to content

Instantly share code, notes, and snippets.

@corck
Last active May 6, 2022 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save corck/d4c63e3908548963ce2e58b45d9976e2 to your computer and use it in GitHub Desktop.
Save corck/d4c63e3908548963ce2e58b45d9976e2 to your computer and use it in GitHub Desktop.
Restart Networkmanager on connection reset, restart VPN after network manager restart
For monitoring Network Manager connection and restart it on a dropped connection (eth/wifi). Make sure to specify the right interface below (eth0, wlan0...)
#/etc/init/reconnect.conf
start on started network-manager
stop on runlevel [016]
script
while true; do
if ifconfig eth0 | grep -q "inet addr:"; then
# echo "all ok!"
else
restart network-manager
fi
sleep 5
done
end script
from `http://askubuntu.com/questions/71528/make-network-manager-restart-after-dropped-connection`
Make sure openvpn restarts after Network Manager restart. For some reason my system (Debian) did not run the scripts in
`/etc/network/if-up.d/` so I created one in `/etc/NetworkManager/dispatch.d` that restarts my VPN after
a network manager restart
#/etc/NetworkManager/dispatcher.d/02script
#!/bin/sh -e
if [ "$2" = "up" ]; then
/etc/init.d/openvpn restart vlora1
fi
exit $?
@corck
Copy link
Author

corck commented Feb 6, 2017

In the first script, make sure you set the proper interface that you want to monitor: eth0 or wlan0 .....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment