-
Notifications
You must be signed in to change notification settings - Fork 0
/
fw
71 lines (56 loc) · 1.69 KB
/
fw
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
#!/bin/bash
. /lib/lsb/init-functions
## functions
start() {
iptables -t filter -F
iptables -t filter -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT DROP
iptables -A INPUT -i lo -j ACCEPT
#libera conexoes estabelecidas anteriormente
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#temporiza X tentativas por minuto SSH
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --set --name SSH
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 120 --hitcount 4 --rttl --name SSH -j LOG --log-prefix "SSH_PROTEC " --log-level info
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 120 --hitcount 4 --rttl --name SSH -j DROP
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
exit 0
}
stop(){
iptables -t filter -F
iptables -t filter -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
}
### selection
case "$1" in
"start")
log_daemon_msg "Iniciando Firewall"
start
log_end_msg 0
;;
"stop")
log_daemon_msg "Finalizando Firewall"
stop
log_end_msg 0
;;
"restart")
stop
start
;;
*)
echo "use os parametros start ou stop"
stop
start
esac
exit 0