From 48396128becb781e563d9ab764a6c8c889e9a332 Mon Sep 17 00:00:00 2001 From: Anri Kennel Date: Sat, 23 Dec 2023 20:38:38 +0100 Subject: [PATCH] Actualiser server --- server.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) 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