How to avoid password prompt in terminal?
Ok, thank you Batman for suggesting to edit the sudoer file. Instead of crontab or launchd to schedule it once a day (which wasn't good enough anyway), I instead wrote that applescript to do it more regularly and so far it seems to be working:

repeat
    repeat
        try
            do shell script "ping -t 15 8.8.8.8"
            exit repeat
        on error
            display notification "Reconnection attempt"
            do shell script "sudo networksetup -setnetworkserviceenabled ethernet off"
            do shell script "sudo networksetup -setnetworkserviceenabled ethernet on"
            delay 9
            display notification "Connection should be established"
        end try
    end repeat
    delay 5
end repeat


I'm adding more details: I exported it as an .app then I edited the .plist of it with the lines:

&lt;key&gt;LSBackgroundOnly&lt;/key&gt;
&lt;string&gt;1&lt;/string&gt;


To make it invisible when it runs (no dock icon) and finally I made it run on login.