Skip to content

Instantly share code, notes, and snippets.

@bpierre
Created December 3, 2012 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpierre/4195109 to your computer and use it in GitHub Desktop.
Save bpierre/4195109 to your computer and use it in GitHub Desktop.
Add a custom domain on a Neuf/SFR Box, from CLI
#!/bin/sh
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 2 ] || die "2 arguments required (IP and Domain), $# provided"
LOGIN="admin"
PASSWORD="YOUR_SFR_BOX_PASSWORD"
LOCAL_IP=$1
NEW_DOMAIN=$2
URL_LOGIN="http://192.168.1.1/login"
URL_DNS="http://192.168.1.1/network/dns"
PARAMS=""
umask 0177
COOKIES_FILENAME="$(mktemp /tmp/cookie.XXXXXX)"
curl -c "$COOKIES_FILENAME" -d"login=${LOGIN}&password=${PASSWORD}" "$URL_LOGIN" > /dev/null 2>&1
i=0
for ip_part in $(echo $LOCAL_IP | tr "." "\n"); do
PARAMS="${PARAMS}dnshosts_ip_p${i}=$ip_part&"
i=$((i+1))
done
PARAMS="${PARAMS}dnshosts_hostname=${NEW_DOMAIN}&action=add"
curl -b "$COOKIES_FILENAME" -d"$PARAMS" "$URL_DNS" > /dev/null 2>&1
rm $COOKIES_FILENAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment