Posts by sangaman
-
-
Is there a fix on the horizon for the issue with using a domain name for Host? This cost me several hours of headache today although fortunately I came across this thread which helped me figure out why I couldn't ping or route any traffic. I tweaked novalis' script and am running it on a cron job that runs every 15 minutes and on reboot, I'm using this instead of a systemd service.
Code
Display Morenewipstr=$(getent ahosts yourdomain.name | grep -o '^[^\.]*.[^\.]*.[^\.]*.[^\ ]*' -m 1) oldipstr=$(sed -n 4p /storage/.config/wireguard/wg0.config | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b") # make servicename by replacing . with _ newservicename=$(echo "vpn_${newipstr}" | tr . _) oldservicename=$(echo "vpn_${oldipstr}" | tr . _) #echo "new service $newservicename" #echo "old service $oldservicename" if [ "$newipstr" = "$oldipstr" ]; then iseq=true #echo "ips same" else # replace line 4 in wireguard.config with actual ip sed -i '4s/.*/Host = '$newipstr'/' /storage/.config/wireguard/wg0.config iseq=false #echo "ips different" fi if [ -z "$(wg)" ]; then # wireguard is not connected connmanctl connect $newservicename else # wireguard is connected if [ "$iseq" != true ]; then connmanctl disconnect $oldservicename connmanctl connect $newservicename fi fi