The command iptables -A POSTROUTING -t nat -s 192.168.1.5 -j MASQUERADE doesn't work if invoked as a user,it says "you must be root". So,as user,the script seems to be working fine like this :
function jumpto { label=$1 cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$') eval "$cmd" exit } start=${1:-"start"} jumpto $start start: warp-cli disconnect OLD_IP="$(curl -s api.ipify.org)" #echo 1 > /proc/sys/net/ipv4/ip_forward (because I've uncommented this command inside the file /etc/sysctl.conf) sudo iptables -A POSTROUTING -t nat -s 192.168.1.5 -j MASQUERADE warp-cli connect NEW_IP="$(curl -s api.ipify.org)" echo Connected to Cloudflare Warp... echo OLD IP is $OLD_IP , NEW IP is $NEW_IP mid : if [ "$OLD_IP = $NEW_IP ] then echo OLD IP is $OLD_IP , NEW IP is $NEW_IP : it does not work anymore,reconnecting... sleep 10 jump foo else echo OLD IP is $OLD_IP , NEW IP is $NEW_IP : it still works. sleep 10 fi jumpto mid foo: warp-cli disconnect OLD_IP="$(curl -s api.ipify.org)" warp-cli connect NEW_IP="$(curl -s api.ipify.org)" echo OLD IP is $OLD_IP , NEW IP is $NEW_IP : it works again. jumpto mid On Mon, May 13, 2024 at 2:59 PM <to...@tuxteam.de> wrote: > On Mon, May 13, 2024 at 02:53:18PM +0200, Nicolas George wrote: > > to...@tuxteam.de (12024-05-13): > > > That's like slicing your morning baguette with the chainsaw. > > > > Worse than that, it will only work from an X11 environment. Certainly > > not at boot. > > The analogy to that would be that not many kitchens are equipped with > a chainsaw. Mine isn't ;-) > > Cheers > -- > t > -- Mario.