From cd4229b97eae3ed42f76909a848c2bdec496a807 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dobrica=20Pavlinu=C5=A1i=C4=87?= Date: Sun, 2 Jul 2023 21:42:59 +0200 Subject: [PATCH] store and restore default route --- srce02-down.sh | 3 +++ srce02-up.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/srce02-down.sh b/srce02-down.sh index 7d44401..f5cf814 100755 --- a/srce02-down.sh +++ b/srce02-down.sh @@ -1,2 +1,5 @@ +#!/bin/sh + kill $( ps ax | grep ssh | grep srce02 | awk '{ print $1 }' ) nmcli c down $( nmcli c | grep gsm | cut -d' ' -f1 ) +grep default /tmp/ip.route | tail -1 | awk '{ print "sudo ip route add",$1,$2,$3 } ' | sh -x diff --git a/srce02-up.sh b/srce02-up.sh index ad17da9..939ea0d 100755 --- a/srce02-up.sh +++ b/srce02-up.sh @@ -2,6 +2,7 @@ # /etc/sudoers.d/user # user ALL=NOPASSWD: ALL +sudo ip route | tee /tmp/ip.route sudo ip route del default # remove default route to ensure that our ssh will be over gsm connection @@ -15,3 +16,5 @@ done ssh -C -N -v -R 22022:localhost:22 dpavlin@srce02.net.ffzg.hr & SSH_PID=$! echo $SSH_PID | tee /tmp/ssh.pid | logger + +ip route -- 2.20.1