13,14 → 13,15 |
ALCASAR_CONF_FILE="/usr/local/etc/alcasar.conf" |
LOCAL_DOMAIN_CONF_FILE="/etc/unbound/conf.d/common/local-forward/dns-redirector.conf" |
LOCAL_HOSTNAME_FILE="/etc/hosts" |
LOCAL_DNS_FILE="/etc/unbound/conf.d/common/local-dns/global.conf" |
|
# define DNS parameters (LAN side) |
INT_DNS_DOMAIN=`grep ^DOMAIN $ALCASAR_CONF_FILE|cut -d"=" -f2` |
INT_DNS_HOST=`grep ^HOSTNAME $ALCASAR_CONF_FILE|cut -d"=" -f2` |
INT_DNS_IP=`grep ^PRIVATE_IP $ALCASAR_CONF_FILE|cut -d"=" -f2|cut -d"/" -f1` |
INTIF=`grep ^INTIF $ALCASAR_CONF_FILE|cut -d"=" -f2` |
INT_DNS_ACTIVE=`grep INT_DNS_ACTIVE $ALCASAR_CONF_FILE|cut -d"=" -f2` |
LOCAL_DNS_FILE="/etc/unbound/conf.d/common/local-dns/$INTIF.conf" |
|
INT_DNS_DOMAIN=`grep INT_DNS_DOMAIN $ALCASAR_CONF_FILE|cut -d"=" -f2` # Nom du domaine DNS interne |
INT_DNS_IP=`grep INT_DNS_IP $ALCASAR_CONF_FILE|cut -d"=" -f2` # Adresse du serveur DNS interne |
INT_DNS_ACTIVE=`grep INT_DNS_ACTIVE $ALCASAR_CONF_FILE|cut -d"=" -f2` # Activation de la redirection DNS interne |
|
usage="Usage: alcasar-dns-local.sh {--on | -on} | {--off | -off} | {--add | -add} ip domain | {--del | -del} ip domain | {--reload | -reload}" |
nb_args=$# |
args=$1 |
38,18 → 39,20 |
} |
|
function hosts_to_unbound(){ |
# Empty the local DNS file |
echo "server:" > $LOCAL_DNS_FILE |
|
cat << EOF > $LOCAL_DNS_FILE |
server: |
local-zone: "$INT_DNS_DOMAIN" static |
local-data: "$INT_DNS_HOST.$INT_DNS_DOMAIN A $INT_DNS_IP" |
local-data-ptr: "$INT_DNS_IP $INT_DNS_HOST.$INT_DNS_DOMAIN" |
EOF |
while read -r line |
do |
ip_address=$(echo $line | awk '{ print $1 }') |
domain=$(echo $line | awk '{ print $2 }') |
|
if ! echo $line | grep -E -q "^([0-9\.\t ]+alcasar( |$)|127\.0\.0)" |
then |
echo -e "\tlocal-zone: \"$domain\" redirect" >> $LOCAL_DNS_FILE |
echo -e "\tlocal-data: \"$domain A $ip_address\"" >> $LOCAL_DNS_FILE |
echo -e "\tlocal-data: \"$domaini.$INT_DNS_DOMAIN A $ip_address\"" >> $LOCAL_DNS_FILE |
echo -e "\tlocal-data-ptr: \"$ip_address $domain.$INT_DNS_DOMAIN\"" >> $LOCAL_DNS_FILE |
fi |
done < $LOCAL_HOSTNAME_FILE |
} |