-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzzfirewall-reset.sh
More file actions
executable file
·59 lines (45 loc) · 1.38 KB
/
zzfirewall-reset.sh
File metadata and controls
executable file
·59 lines (45 loc) · 1.38 KB
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
#!/usr/bin/env bash
### FACTORY-RESET IPTABLES
# clear && sudo apt install curl -y && curl -s https://raw.githubusercontent.com/TurboLabIt/zzfirewall/main/zzfirewall-reset.sh | sudo bash
## bash-fx
if [ -f "/usr/local/turbolab.it/bash-fx/bash-fx.sh" ]; then
source "/usr/local/turbolab.it/bash-fx/bash-fx.sh"
else
source <(curl -s https://raw.githubusercontent.com/TurboLabIt/bash-fx/main/bash-fx.sh)
fi
## bash-fx is ready
fxHeader "❤️🩹 FIREWALL RESET"
rootCheck
if [ "$1" = "light" ]; then
LIGHT_MODE=1
else
LIGHT_MODE=0
fi
if [ "$LIGHT_MODE" = 0 ]; then
fxTitle "🧹 Removing ufw, iptables-persistent..."
apt purge ufw iptables-persistent -y
fi
fxTitle "🔄 Restoring iptables to default..."
iptables-save | awk '/^[*]/ { print $1 }
/^:[A-Z]+ [^-]/ { print $1 " ACCEPT" ; }
/COMMIT/ { print $0; }' | iptables-restore
if [ "$LIGHT_MODE" = 0 ] && [ ! -z "$(command -v ipset)" ]; then
fxTitle "🧹 Remove all ipsets..."
ipset flush
## Set cannot be destroyed: it is in use by a kernel component
# https://github.com/weaveworks/weave/issues/3847
sleep 2
ipset destroy
if [ $? -ne 0 ]; then
fxMessage "Failed - retrying..."
sleep 3
ipset destroy
fi
fi
fxTitle "🧱 Current status"
iptables -nL
if [ "$LIGHT_MODE" = 0 ] && [ ! -z "$(command -v ipset)" ]; then
echo ""
ipset list
fi
fxEndFooter