ddns

uno script facile facile per configurarsi i dns:

#/bin/bash
usage(){
if [ $# -eq 0 ];then
echo “Usage $0:
show        print your dns in $FILE
fastweb        213.140.2.12 / 213.140.2.21
normal        192.168.1.1
normal0        192.168.0.1
gw        set like default gw
go        8.8.8.8 / 4.2.2.2
open        opendns: 208.67.222.222 / 208.67.220.220
libero        193.70.192.100 195.210.91.10”
else
echo “$@”
fi
exit 1
}
FILE=”/etc/resolv.conf”

case $1 in
“gw”)
GW=$(route -n | tail -1 | awk ‘{print $2}’)
PRIMARIO=$GW
;;
show)
echo “= $FILE =”
cat $FILE
exit 0
;;
“fastweb”)
PRIMARIO=”213.140.2.12″
SECONDARIO=”213.140.2.21″
;;
“normal”)
PRIMARIO=”192.168.1.1″
;;
“normal0″)
PRIMARIO=”192.168.0.1”
;;
“open”)
PRIMARIO=”208.67.222.222″;
SECONDARIO=”208.67.220.220″
;;
“go”)
PRIMARIO=”8.8.8.8″
SECONDARIO=”4.2.2.2″;
;;
“libero”)
PRIMARIO=”193.70.192.100″;
SECONDARIO=”195.210.91.10″;
;;
*)
usage
;;
esac

[ “$SECONDARIO” = “” ] && SECONDARIO=”4.2.2.2″

echo ”
DNS auto-change using $0
nameserver $PRIMARIO
nameserver $SECONDARIO” | sudo tee $FILE

This entry was posted in hacks and tagged , , . Bookmark the permalink.