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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
| #Switch to root mode
sudo su
#Define dcompass version
dcompass_version=build-20210803_1007
#Create dcompass temp folder
sudo mkdir -p /tmp/dcompass
# Swich to folder just we created.
cd /tmp/dcompass
#Download dcompass binary
sudo curl -fsSLO "https://github.com/LEXUGE/dcompass/releases/download/$dcompass_version/dcompass-x86_64-unknown-linux-musl-full"
#Create dcompass configure folder
sudo mkdir -p /etc/dcompass
#Create dcompass configure yaml file
sudo bash -c 'cat > /etc/dcompass/config.yaml' <<EOF
---
verbosity: "info"
#address: 0.0.0.0:2053
address: 127.0.1.2:53
table:
start:
if:
qtype:
- AAAA
then:
# A list of actions is allowed here
- blackhole
# The next tag to go
- end
else:
- dispatch
dispatch:
if: any
then:
- query: domestic
- check_secure
check_secure:
if:
geoip:
codes:
- CN
else:
- query: aboard
- end
upstreams:
114DNS:
udp:
addr: 114.114.114.114:53
Ali:
udp:
addr: 223.6.6.6:53
domestic:
hybrid:
- 114DNS
- Ali
googledns1:
udp:
addr: 8.8.8.8:53
googledns2:
udp:
addr: 8.8.4.4:53
aboard:
hybrid:
- googledns1
- googledns2
EOF
sudo cp -af /tmp/dcompass/dcompass-x86_64-unknown-linux-musl-full /usr/local/bin/dcompass
sudo chown root:root /usr/local/bin/dcompass
sudo chmod +x /usr/local/bin/dcompass
sudo bash -c 'cat > /lib/systemd/system/dcompass.service' << EOF
[Unit]
Description=dcompass service
[Service]
ExecStart=/usr/local/bin/dcompass -c /etc/dcompass/config.yaml
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
EOF
#Reload systemclt daemon
sudo systemctl daemon-reload
#Delete temp directory.
sudo rm -rf /tmp/dcompass
#Enable service of dcompass auto startup when system reboot
sudo systemctl enable dcompass
#Restart service of dcompass
sudo systemctl restart dcompass
#Check dcompass status of dcompass.
sudo systemctl status dcompass
|