2223 |
tom.houday |
1 |
#!/bin/bash
|
|
|
2 |
# $Id: alcasar-dns-local.sh 2262 2017-05-29 20:19:03Z tom.houdayer $
|
1607 |
franck |
3 |
|
|
|
4 |
# alcasar-dns-interne.sh
|
|
|
5 |
# by Rexy - 3abtux
|
|
|
6 |
# This script is distributed under the Gnu General Public License (GPL)
|
|
|
7 |
|
|
|
8 |
# active ou desactive la redirection du service DNS sur le réseau de consultation
|
|
|
9 |
# enable or disable the redirector of internal DNS service on consultation LAN
|
|
|
10 |
|
|
|
11 |
SED="/bin/sed -i"
|
|
|
12 |
|
|
|
13 |
ALCASAR_CONF_FILE="/usr/local/etc/alcasar.conf"
|
1614 |
franck |
14 |
DNSMASQ_CONF_FILE="/etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf /etc/dnsmasq-blacklist.conf /etc/dnsmasq-whitelist.conf"
|
1607 |
franck |
15 |
DNSMASQ_CONF_LOCAL_FILE="/usr/local/etc/alcasar-dns-name"
|
|
|
16 |
|
|
|
17 |
# define DNS parameters (LAN side)
|
|
|
18 |
|
|
|
19 |
INT_DNS_DOMAIN=`grep INT_DNS_DOMAIN $ALCASAR_CONF_FILE|cut -d"=" -f2` # Nom du domaine DNS interne
|
|
|
20 |
INT_DNS_IP=`grep INT_DNS_IP $ALCASAR_CONF_FILE|cut -d"=" -f2` # Adresse du serveur DNS interne
|
|
|
21 |
INT_DNS_ACTIVE=`grep INT_DNS_ACTIVE $ALCASAR_CONF_FILE|cut -d"=" -f2` # Activation de la redirection DNS interne
|
|
|
22 |
|
|
|
23 |
usage="Usage: alcasar-dns-interne.sh {--on | -on} | {--off | -off}"
|
|
|
24 |
nb_args=$#
|
|
|
25 |
args=$1
|
|
|
26 |
if [ $nb_args -eq 0 ]
|
|
|
27 |
then
|
|
|
28 |
echo "$usage"
|
|
|
29 |
exit 1
|
|
|
30 |
fi
|
|
|
31 |
case $args in
|
|
|
32 |
-\? | -h | --h)
|
|
|
33 |
echo "$usage"
|
|
|
34 |
exit 0
|
|
|
35 |
;;
|
|
|
36 |
--off|-off) # disable DNS redirector
|
|
|
37 |
$SED "s?^#filterwin2k.*?filterwin2k?g" $DNSMASQ_CONF_FILE
|
|
|
38 |
$SED "s?^server.*?#&?g" $DNSMASQ_CONF_LOCAL_FILE
|
|
|
39 |
$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=off?g" $ALCASAR_CONF_FILE
|
|
|
40 |
|
|
|
41 |
/usr/bin/systemctl restart dnsmasq
|
|
|
42 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
|
|
43 |
/usr/bin/systemctl restart dnsmasq-blackhole
|
|
|
44 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
|
|
45 |
;;
|
|
|
46 |
--on|-on) # enable DHCP service on all range of IP addresses
|
|
|
47 |
$SED "s?^filterwin2k.*?#filterwin2k?g" $DNSMASQ_CONF_FILE
|
1616 |
franck |
48 |
$SED "s?^server=/.*?server=/$INT_DNS_DOMAIN/$INT_DNS_IP?g" $DNSMASQ_CONF_LOCAL_FILE
|
1607 |
franck |
49 |
$SED "s?^#server=/.*?server=/$INT_DNS_DOMAIN/$INT_DNS_IP?g" $DNSMASQ_CONF_LOCAL_FILE
|
|
|
50 |
$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=on?g" $ALCASAR_CONF_FILE
|
|
|
51 |
|
|
|
52 |
/usr/bin/systemctl restart dnsmasq
|
|
|
53 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
|
|
54 |
/usr/bin/systemctl restart dnsmasq-blackhole
|
|
|
55 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
|
|
56 |
;;
|
|
|
57 |
*)
|
|
|
58 |
echo "Argument inconnu :$1";
|
|
|
59 |
echo "$usage"
|
|
|
60 |
exit 1
|
|
|
61 |
;;
|
|
|
62 |
esac
|