-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-firewall.sh
More file actions
49 lines (42 loc) · 861 Bytes
/
update-firewall.sh
File metadata and controls
49 lines (42 loc) · 861 Bytes
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
ALLOWED_HOSTS_URL="https://sshfs.net/allowed_hosts.txt"
ALLOWED_IPS_URL="https://sshfs.net/allowed_ips.txt"
echo
echo "Downloading Allow Files..."
echo
wget -nv $ALLOWED_HOSTS_URL -O allowed.hosts
wget -nv $ALLOWED_IPS_URL -O allowed.ips
echo
echo "Resolving Allowed Hosts..."
echo
readarray domains < allowed.hosts
for i in ${domains[@]}; do
IPv4=`dig $i A +short`
echo "$IPv4" >> ip.tmp
IPv6=`dig $i AAAA +short`
echo "$i"
echo "IPv4: $IPv4"
echo "IPv6: $IPv6"
echo "----------"
echo "$IPv6" >> ip.tmp
done
echo
echo "Adding Allowed IP Addresses..."
echo
cat allowed.ips
cat allowed.ips >> ip.tmp
echo
echo
echo "Updating Firewall Rules..."
echo
readarray a < ip.tmp
for i in ${a[@]}; do
ufw allow from $i
done
rm ip.tmp
echo
echo
ufw status numbered
echo
echo "Done!"
echo
exit