1607 |
franck |
1 |
#/bin/bash
|
|
|
2 |
# $Id: alcasar-dhcp.sh 1484 2014-11-11 23:14:36Z richard $
|
|
|
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"
|
|
|
14 |
DNSMASQ_CONF_FILE="/etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf /etc/dnsmasq-blacklist.sh /etc/dnsmasq-whitelist.conf"
|
|
|
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
|
|
|
48 |
$SED "s?^#server=/.*?server=/$INT_DNS_DOMAIN/$INT_DNS_IP?g" $DNSMASQ_CONF_LOCAL_FILE
|
|
|
49 |
$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=on?g" $ALCASAR_CONF_FILE
|
|
|
50 |
|
|
|
51 |
/usr/bin/systemctl restart dnsmasq
|
|
|
52 |
/usr/bin/systemctl restart dnsmasq-blacklist
|
|
|
53 |
/usr/bin/systemctl restart dnsmasq-blackhole
|
|
|
54 |
/usr/bin/systemctl restart dnsmasq-whitelist
|
|
|
55 |
;;
|
|
|
56 |
*)
|
|
|
57 |
echo "Argument inconnu :$1";
|
|
|
58 |
echo "$usage"
|
|
|
59 |
exit 1
|
|
|
60 |
;;
|
|
|
61 |
esac
|
|
|
62 |
|