diff --git a/server.md b/server.md index ae409a4..66aa50c 100644 --- a/server.md +++ b/server.md @@ -1,10 +1,31 @@ -only reboot if vpn isn't used +# only reboot if vpn isn't used + ```bash if [ $(ifstat -i tun0 1s 1 | awk 'NR==3 {print $1}' | sed 's#\..*##') -eq 0 ]; then systemctl reboot; fi ``` -fix routing +# fix routing + > replace `` by the IP + +## `routing.sh` + +```bash +#!/bin/bash + +# supression d'une ancienne route +ip route del 2> /dev/null +# ajoute de la nouvelle route avec la bonne IP +ip route add via $(ip -4 -br addr show tun0 | awk '{split($3,a,"/"); print a[1]}') dev tun0 + +echo "Done :)" + +# vérification +# ip route +``` + +## run the script + ```bash if [ $(ip route | grep | wc -l) -ne 1 ]; then /root/openvpn/routing.sh; fi -``` +``` \ No newline at end of file