Subversion Repositories ALCASAR

Rev

Rev 2861 | Rev 2964 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2861 Rev 2947
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-dns-local.sh 2861 2020-10-04 20:41:06Z rexy $
2
# $Id: alcasar-dns-local.sh 2947 2021-04-21 16:36:52Z rexy $
3
 
3
 
4
# alcasar-dns-local.sh
4
# alcasar-dns-local.sh
5
# by Rexy - 3abtux
5
# by Rexy - 3abtux
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
Line 33... Line 33...
33
fi
33
fi
34
 
34
 
35
function restart_dns(){
35
function restart_dns(){
36
	for dns in unbound unbound-blacklist unbound-whitelist dnsmasq-whitelist unbound-blackhole
36
	for dns in unbound unbound-blacklist unbound-whitelist dnsmasq-whitelist unbound-blackhole
37
	do
37
	do
-
 
38
		echo "Restarting $dns. Please wait..."
38
		systemctl restart $dns
39
		systemctl restart $dns
39
	done
40
	done
40
}
41
}
41
 
42
 
42
function hosts_to_unbound(){  # configure the unbound conf file with local host names resolution
43
function hosts_to_unbound(){  # configure the unbound conf file with local host names resolution
Line 97... Line 98...
97
	--off|-off) # disable DNS redirector
98
	--off|-off) # disable DNS redirector
98
		#$SED "s?^#filterwin2k.*?filterwin2k?g" $DNSMASQ_CONF_FILE
99
		#$SED "s?^#filterwin2k.*?filterwin2k?g" $DNSMASQ_CONF_FILE
99
		rm -f $LOCAL_DOMAIN_CONF_FILE
100
		rm -f $LOCAL_DOMAIN_CONF_FILE
100
		$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=off?g" $ALCASAR_CONF_FILE
101
		$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=off?g" $ALCASAR_CONF_FILE
101
		restart_dns
102
		restart_dns
-
 
103
		/usr/local/bin/alcasar-iptables.sh
102
 
104
		;;
-
 
105
	--off-without-restart|-off-without-restart) # disable DNS redirector
-
 
106
		#$SED "s?^#filterwin2k.*?filterwin2k?g" $DNSMASQ_CONF_FILE
-
 
107
		rm -f $LOCAL_DOMAIN_CONF_FILE
-
 
108
		$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=off?g" $ALCASAR_CONF_FILE
103
		# Reload firewall
109
		restart_dns
104
		/usr/local/bin/alcasar-iptables.sh
110
		/usr/local/bin/alcasar-iptables.sh
105
		;;
111
		;;
106
	--on|-on) # enable DNS redirector
112
	--on|-on) # enable DNS redirector
107
		#$SED "s?^filterwin2k.*?#filterwin2k?g" $DNSMASQ_CONF_FILE
113
		#$SED "s?^filterwin2k.*?#filterwin2k?g" $DNSMASQ_CONF_FILE
108
		cat > $LOCAL_DOMAIN_CONF_FILE << EOF
114
		cat > $LOCAL_DOMAIN_CONF_FILE << EOF
Line 111... Line 117...
111
forward-zone:
117
forward-zone:
112
	name: "$INT_DNS_DOMAIN."
118
	name: "$INT_DNS_DOMAIN."
113
	forward-addr: $INT_DNS_IP
119
	forward-addr: $INT_DNS_IP
114
EOF
120
EOF
115
		$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=on?g" $ALCASAR_CONF_FILE
121
		$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=on?g" $ALCASAR_CONF_FILE
-
 
122
		/usr/local/bin/alcasar-iptables.sh
-
 
123
		;;
-
 
124
	--on-without-restart|-on-without-restart) # enable DNS redirector
-
 
125
		#$SED "s?^filterwin2k.*?#filterwin2k?g" $DNSMASQ_CONF_FILE
-
 
126
		cat > $LOCAL_DOMAIN_CONF_FILE << EOF
-
 
127
server:
-
 
128
    local-zone: "$INT_DNS_DOMAIN." transparent
116
		restart_dns
129
forward-zone:
-
 
130
	name: "$INT_DNS_DOMAIN."
117
		# Reload firewall
131
	forward-addr: $INT_DNS_IP
-
 
132
EOF
-
 
133
		$SED "s?^INT_DNS_ACTIVE.*?INT_DNS_ACTIVE=on?g" $ALCASAR_CONF_FILE
118
		/usr/local/bin/alcasar-iptables.sh
134
		/usr/local/bin/alcasar-iptables.sh
119
		;;
135
		;;
120
	*)
136
	*)
121
		echo "Argument inconnu : $1";
137
		echo "Argument inconnu : $1";
122
		echo "$usage"
138
		echo "$usage"