-
Notifications
You must be signed in to change notification settings - Fork 0
/
firewall.sh
63 lines (49 loc) · 1.01 KB
/
firewall.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Atualizado em 31/08/16 por Rui Ribeiro - rui.ribeiro@cafe.rnp.br
RULES_FILE="/etc/default/firewall"
RETVAL=0
# To start the firewall
start() {
# Termina se nao existe iptables
[ -x /sbin/iptables ] || exit 0
# Arquivo com as regras propriamente ditas
if [ -f "$RULES_FILE" ]; then
echo "Carregando regras de firewall ..."
. $RULES_FILE
else
echo "Arquivo de regras inexistente: $RULES_FILE"
stop
RETVAL=1
fi
RETVAL=0
}
# To stop the firewall
stop() {
echo "Removendo todas as regras de firewall ..."
iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -Z
RETVAL=0
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
/sbin/iptables -L
/sbin/iptables -t nat -L
RETVAL=0
;;
*)
echo "Uso: $1 {start|stop|restart|status}"
RETVAL=1;;
esac
exit $RETVAL