Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar-conf.sh 2831 2020-06-07 21:43:19Z rexy $
|
2 |
# $Id: alcasar-conf.sh 2833 2020-06-14 10:13:18Z rexy $
|
3 |
|
3 |
|
4 |
# alcasar-conf.sh
|
4 |
# alcasar-conf.sh
|
5 |
# by REXY
|
5 |
# by REXY
|
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 151... |
Line 151... |
151 |
[ -e $DIR_UPDATE/etc/alcasar-iptables-local-mac-filtered ] && cp -f $DIR_UPDATE/etc/alcasar-iptables-local-mac-filtered $DIR_ETC/ # blocked MAC addresses
|
151 |
[ -e $DIR_UPDATE/etc/alcasar-iptables-local-mac-filtered ] && cp -f $DIR_UPDATE/etc/alcasar-iptables-local-mac-filtered $DIR_ETC/ # blocked MAC addresses
|
152 |
[ -e $DIR_UPDATE/etc/alcasar-uamdomain ] && cp -f $DIR_UPDATE/etc/alcasar-uamdomain $DIR_ETC/ # exception domain names
|
152 |
[ -e $DIR_UPDATE/etc/alcasar-uamdomain ] && cp -f $DIR_UPDATE/etc/alcasar-uamdomain $DIR_ETC/ # exception domain names
|
153 |
[ -e $DIR_UPDATE/etc/alcasar-uamallowed ] && cp -f $DIR_UPDATE/etc/alcasar-uamallowed $DIR_ETC/ # exception IP_addresses or network_IP_addresses
|
153 |
[ -e $DIR_UPDATE/etc/alcasar-uamallowed ] && cp -f $DIR_UPDATE/etc/alcasar-uamallowed $DIR_ETC/ # exception IP_addresses or network_IP_addresses
|
154 |
[ -e $DIR_UPDATE/etc/alcasar-ethers ] && cp -f $DIR_UPDATE/etc/alcasar-ethers $DIR_ETC/ # DHCP static hosts
|
154 |
[ -e $DIR_UPDATE/etc/alcasar-ethers ] && cp -f $DIR_UPDATE/etc/alcasar-ethers $DIR_ETC/ # DHCP static hosts
|
155 |
[ -e $DIR_UPDATE/etc/alcasar-ethers-info ] && cp -f $DIR_UPDATE/etc/alcasar-ethers-info $DIR_ETC/ # DHCP static hosts information
|
155 |
[ -e $DIR_UPDATE/etc/alcasar-ethers-info ] && cp -f $DIR_UPDATE/etc/alcasar-ethers-info $DIR_ETC/ # DHCP static hosts information
|
156 |
[ -e $DIR_UPDATE/etc/hosts ] && cp -f $DIR_UPDATE/etc/hosts /etc/ && $DIR_BIN/alcasar-dns-local.sh -hosts_to_unbound # local hosts name
|
156 |
[ -e $DIR_UPDATE/etc/hosts ] && cp -f $DIR_UPDATE/etc/hosts /etc/ # local host name resolution
|
157 |
# Retrieve BL/WL custom files
|
157 |
# Retrieve BL/WL custom files
|
158 |
cp -f $DIR_UPDATE/custom_bl/exceptioniplist $DIR_E2G/
|
158 |
cp -f $DIR_UPDATE/custom_bl/exceptioniplist $DIR_E2G/
|
159 |
cp -f $DIR_UPDATE/custom_bl/exceptionsitelist $DIR_E2G/
|
159 |
cp -f $DIR_UPDATE/custom_bl/exceptionsitelist $DIR_E2G/
|
160 |
cp -f $DIR_UPDATE/custom_bl/urlregexplist $DIR_E2G/
|
160 |
cp -f $DIR_UPDATE/custom_bl/urlregexplist $DIR_E2G/
|
161 |
cp -f $DIR_UPDATE/custom_bl/bannedsitelist $DIR_E2G/
|
161 |
cp -f $DIR_UPDATE/custom_bl/bannedsitelist $DIR_E2G/
|
Line 375... |
Line 375... |
375 |
forward-zone:
|
375 |
forward-zone:
|
376 |
name: "."
|
376 |
name: "."
|
377 |
forward-addr: $DNS1
|
377 |
forward-addr: $DNS1
|
378 |
forward-addr: $DNS2
|
378 |
forward-addr: $DNS2
|
379 |
EOF
|
379 |
EOF
|
380 |
# Configuration file of ALCASAR main domains for $INTIF
|
- |
|
381 |
cat << EOF > /etc/unbound/conf.d/common/local-dns/${INTIF}.conf
|
- |
|
382 |
server:
|
- |
|
383 |
local-zone: "$DOMAIN" static
|
- |
|
384 |
local-data: "$HOSTNAME.$DOMAIN A $PRIVATE_IP"
|
- |
|
385 |
local-data-ptr: "$PRIVATE_IP $HOSTNAME.$DOMAIN"
|
- |
|
386 |
EOF
|
- |
|
387 |
if [ "$HOSTNAME" != 'alcasar' ]
|
- |
|
388 |
then
|
- |
|
389 |
echo -e "\tlocal-zone: \"alcasar\" static" >> /etc/unbound/conf.d/common/local-dns/${INTIF}.conf
|
- |
|
390 |
echo -e "\tlocal-zone: \"alcasar A $PRIVATE_IP\"" >> /etc/unbound/conf.d/common/local-dns/${INTIF}.conf
|
- |
|
391 |
echo -e "\tlocal-zone: \"alcasar\" static" >> /etc/unbound/conf.d/forward/iface.lo.conf
|
- |
|
392 |
echo -e "\tlocal-zone: \"alcasar A 127.0.0.1\"" >> /etc/unbound/conf.d/forward/iface.lo.conf
|
- |
|
393 |
fi
|
- |
|
394 |
# Configuration file for lo of forward
|
380 |
# Configuration file for lo of forward
|
395 |
cat << EOF > /etc/unbound/conf.d/forward/iface.lo.conf
|
381 |
cat << EOF > /etc/unbound/conf.d/forward/iface.lo.conf
|
396 |
server:
|
382 |
server:
|
397 |
interface: 127.0.0.1@53
|
383 |
interface: 127.0.0.1@53
|
398 |
access-control-view: 127.0.0.1/8 lo
|
384 |
access-control-view: 127.0.0.1/8 lo
|
Line 427... |
Line 413... |
427 |
access-control: $PRIVATE_IP_MASK allow
|
413 |
access-control: $PRIVATE_IP_MASK allow
|
428 |
access-control-tag: $PRIVATE_IP_MASK "whitelist"
|
414 |
access-control-tag: $PRIVATE_IP_MASK "whitelist"
|
429 |
access-control-tag-action: $PRIVATE_IP_MASK "whitelist" redirect
|
415 |
access-control-tag-action: $PRIVATE_IP_MASK "whitelist" redirect
|
430 |
access-control-tag-data: $PRIVATE_IP_MASK "whitelist" "A $PRIVATE_IP"
|
416 |
access-control-tag-data: $PRIVATE_IP_MASK "whitelist" "A $PRIVATE_IP"
|
431 |
EOF
|
417 |
EOF
|
432 |
# Configuration file for $INTIF of blackhole
|
- |
|
433 |
cat << EOF > /etc/unbound/conf.d/blackhole/iface.${INTIF}.conf
|
- |
|
434 |
server:
|
- |
|
435 |
interface: ${PRIVATE_IP}@56
|
- |
|
436 |
access-control-view: $PRIVATE_NETWORK_MASK $INTIF
|
- |
|
437 |
view:
|
- |
|
438 |
name: "$INTIF"
|
- |
|
439 |
local-zone: "." redirect
|
- |
|
440 |
local-data: ". A $PRIVATE_IP"
|
- |
|
441 |
EOF
|
- |
|
442 |
# dhcpd
|
418 |
# dhcpd
|
443 |
cat <<EOF > /etc/dhcpd.conf
|
419 |
cat <<EOF > /etc/dhcpd.conf
|
444 |
ddns-update-style none;
|
420 |
ddns-update-style none;
|
445 |
subnet $PRIVATE_NETWORK netmask $PRIVATE_NETMASK {
|
421 |
subnet $PRIVATE_NETWORK netmask $PRIVATE_NETMASK {
|
446 |
option routers $PRIVATE_IP;
|
422 |
option routers $PRIVATE_IP;
|
Line 449... |
Line 425... |
449 |
range dynamic-bootp $PRIVATE_SECOND_IP $PRIVATE_LAST_IP;
|
425 |
range dynamic-bootp $PRIVATE_SECOND_IP $PRIVATE_LAST_IP;
|
450 |
default-lease-time 21600;
|
426 |
default-lease-time 21600;
|
451 |
max-lease-time 43200;
|
427 |
max-lease-time 43200;
|
452 |
}
|
428 |
}
|
453 |
EOF
|
429 |
EOF
|
- |
|
430 |
$DIR_BIN/alcasar-dns-local.sh -hosts_to_unbound # add local name resoution to unbound (forward & blackhole)
|
454 |
# tinyproxy
|
431 |
# tinyproxy
|
455 |
$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
|
432 |
$SED "s?^Listen.*?Listen $PRIVATE_IP?g" /etc/tinyproxy/tinyproxy.conf
|
456 |
# DG + BL
|
433 |
# DG + BL
|
457 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/e2guardian/e2guardian.conf
|
434 |
$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/e2guardian/e2guardian.conf
|
458 |
# Watchdog
|
435 |
# Watchdog
|