View difference between Paste ID: FcjhPfKa and N7MkZrQy
SHOW: | | - or go back to the newest paste.
1-
#!/bin/bash
1+
#!/bin/bash
2-
2+
3-
# Vider les tables actuelles
3+
# Vider les tables actuelles
4-
iptables -t filter -F
4+
iptables -t filter -F
5-
5+
6-
# Vider les règles personnelles
6+
# Vider les règles personnelles
7-
iptables -t filter -X
7+
iptables -t filter -X
8-
8+
9-
# Interdire toute connexion entrante et sortante
9+
# Interdire toute connexion entrante et sortante
10-
iptables -t filter -P INPUT DROP
10+
iptables -t filter -P INPUT DROP
11-
iptables -t filter -P FORWARD DROP
11+
iptables -t filter -P FORWARD DROP
12-
iptables -t filter -P OUTPUT ACCEPT # On va autoriser toutes les requetes sortantes
12+
iptables -t filter -P OUTPUT ACCEPT # On va autoriser toutes les requêtes sortantes
13-
13+
14-
# ---
14+
# ---
15-
15+
16-
# Ne pas casser les connexions etablies
16+
# Ne pas casser les connexions etablies
17-
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
17+
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
18-
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
18+
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
19-
19+
20-
# Autoriser loopback
20+
# Autoriser loopback
21-
iptables -t filter -A INPUT -i lo -j ACCEPT
21+
iptables -t filter -A INPUT -i lo -j ACCEPT
22-
iptables -t filter -A OUTPUT -o lo -j ACCEPT
22+
iptables -t filter -A OUTPUT -o lo -j ACCEPT
23-
23+
24-
# ICMP (Ping)
24+
# ICMP (Ping)
25-
iptables -t filter -A INPUT -p icmp -j ACCEPT
25+
iptables -t filter -A INPUT -p icmp -j ACCEPT
26-
iptables -t filter -A OUTPUT -p icmp -j ACCEPT
26+
iptables -t filter -A OUTPUT -p icmp -j ACCEPT
27-
27+
28-
# ---
28+
# ---
29-
29+
30-
# SSH In
30+
# SSH In
31-
iptables -t filter -A INPUT -p tcp --dport 666 -j ACCEPT
31+
iptables -t filter -A INPUT -p tcp --dport 666 -j ACCEPT
32-
32+
33-
# SSH Out
33+
# SSH Out
34-
iptables -t filter -A OUTPUT -p tcp --dport 666 -j ACCEPT
34+
iptables -t filter -A OUTPUT -p tcp --dport 666 -j ACCEPT
35-
35+
36-
# DNS In/Out
36+
# DNS In/Out
37-
iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
37+
iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
38-
iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
38+
iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
39-
iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
39+
iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
40-
iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT
40+
iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT
41-
41+
42-
# NTP
42+
# NTP
43-
iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT
43+
iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT
44-
44+
45-
# Mail SMTP:25
45+
# Mail SMTP:25
46-
iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
46+
iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
47-
iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
47+
iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
48-
48+
49-
# Banlist
49+
# Banlist
50-
iptables -t filter -A INPUT -p udp --dport 1311 -j ACCEPT
50+
iptables -t filter -A INPUT -p udp --dport 1311 -j ACCEPT
51-
iptables -t filter -A OUTPUT -p udp --dport 1311 -j ACCEPT
51+
iptables -t filter -A OUTPUT -p udp --dport 1311 -j ACCEPT
52-
52+
53-
# FTP Out
53+
# FTP Out
54-
iptables -t filter -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
54+
#iptables -t filter -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
55-
55+
56-
# FTP In
56+
# FTP In
57-
modprobe ip_conntrack_ftp # ligne facultative avec les serveurs OVH
57+
#modprobe ip_conntrack_ftp # ligne facultative avec les serveurs OVH
58-
iptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPT
58+
#iptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPT
59-
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
59+
#iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
60-
60+
61-
# DDoS
61+
# DDoS
62-
iptables -A FORWARD -p tcp --syn -m limit --limit 1/second -j ACCEPT
62+
iptables -A FORWARD -p tcp --syn -m limit --limit 1/second -j ACCEPT
63-
iptables -A FORWARD -p udp -m limit --limit 1/second -j ACCEPT
63+
iptables -A FORWARD -p udp -m limit --limit 1/second -j ACCEPT
64-
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/second -j ACCEPT
64+
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/second -j ACCEPT
65-
65+
66-
# Scan de ports
66+
# Scan de ports
67
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT