-
Notifications
You must be signed in to change notification settings - Fork 1
/
dnsmasq_jail.sh
executable file
·41 lines (41 loc) · 2.21 KB
/
dnsmasq_jail.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/csh
if ($#argv != 1) then
echo "Use: $0 jailName"
exit 0
else
##PRE
##pkg install diffutils wget
set JAIL = "$1"
set JAILMOUNTPOINT = "/mnt/jails"
set CONFIGS = "config"
service jail restart $JAIL
pkg -j $JAIL install dnsmasq
echo dnsmasq_enable="YES" >> $JAILMOUNTPOINT/$JAIL/etc/rc.conf
# create required directories
# mkdir /usr/local/etc/{dnsmasq.conf,hosts}.d
# create a new file for hosts & addresses
cp $CONFIGS/10-custom.conf $JAILMOUNTPOINT/$JAIL/usr/local/etc/dnsmasq.conf.d/
##Check with diff before copy
##diff $CONFIGS/dnsmasq_rcd $JAILMOUNTPOINT/$JAIL/usr/local/etc/rc.d/dnsmasq
##diff $CONFIGS/dnsmasq_conf $JAILMOUNTPOINT/$JAIL/usr/local/etc/dnsmasq.conf
cp $CONFIGS/dnsmasq_rcd $JAILMOUNTPOINT/$JAIL/usr/local/etc/rc.d/dnsmasq
cp $CONFIGS/dnsmasq_conf $JAILMOUNTPOINT/$JAIL/usr/local/etc/dnsmasq.conf
# grab some configs
wget --no-check-certificate https://github.com/raw/acidwars/AdBlock-Lists/master/adblock.conf -O $JAILMOUNTPOINT/$JAIL//usr/local/etc/dnsmasq.conf.d/20-adblock.conf
wget --no-check-certificate https://github.com/raw/acidwars/AdBlock-Lists/master/ads01.conf -O $JAILMOUNTPOINT/$JAIL//usr/local/etc/dnsmasq.conf.d/21-ads01.conf
wget --no-check-certificate https://github.com/raw/notracking/hosts-blocklists/master/domains.txt -O $JAILMOUNTPOINT/$JAIL//usr/local/etc/dnsmasq.conf.d/22-blocklists.conf
# grab some hosts
wget --no-check-certificate https://github.com/raw/r-a-y/mobile-hosts/master/AdguardDNS.txt -O $JAILMOUNTPOINT/$JAIL//usr/local/etc/hosts.d/adguard
wget --no-check-certificate https://github.com/raw/r-a-y/mobile-hosts/master/AdguardMobileAds.txt -O $JAILMOUNTPOINT/$JAIL//usr/local/etc/hosts.d/adguard-mobile
##POST
##Pass port from jail to host with pf or prefered firewall
##Test config
## dnsmasq --test #ON JAIL
##Check config
## dnsmasq -d -q #ON JAIL
## drill freebsd.org @ipjail #ON HOST
##Start service
## service dnsmasq start
echo "dnsmasq_enable=\"YES\"" >> $JAILMOUNTPOINT/$JAIL/etc/rc.conf
echo "dnsmasq_conf=\"/usr/local/etc/dnsmasq.conf\"">> $JAILMOUNTPOINT/$JAIL/etc/rc.conf
endif