Skip to main content

DynDNS sur script Linux

Attribution des droits sur le script

sudo chmod 700 /usr/local/sbin/dyndns.sh 

Exécution du script manuellement 

sudo /usr/local/sbin/dyndns.sh

Vous devriez avoir un retour ressemblant à nochg 91.130.39.102 ou good 91.130.39.102, avec votre IP publique à la place.

Automatiser l'exécution du script

sudo crontab -e 

A la fin du fichier ajouter la ligne suivante :

« */5 * * * * /usr/local/sbin/dyndns.sh > /dev/null 2>&1 »

L'exécution du script est définie toutes les 5 minutes

Script vierge

#!/bin/sh

#Define your OVH DynHost ID & password and the domain name for which you wish to update DynHost

DYNHOST_ID=''
DYNHOST_PASSWORD=''
DOMAIN_NAME=''

#####################
####DO NOT TOUCH#####
#####################

PUBLIC_IP=$(host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}')
#Call OVH for update
curl --silent --user "$DYNHOST_ID:$DYNHOST_PASSWORD" "https://www.ovh.com/nic/update?system=dyndns&hostname=$DOMAIN_NAME&myip=$PUBLIC_IP"