Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo Setting firewall rules...
- #
- #
- ###### Debut Initialisation ######
- # Interdire toute connexion entrante
- iptables -t filter -P INPUT DROP
- iptables -t filter -P FORWARD DROP
- echo - Interdire toute connexion entrante : [OK]
- # Interdire toute connexion sortante
- iptables -t filter -P OUTPUT DROP
- echo - Interdire toute connexion sortante : [OK]
- # Vider les tables actuelles
- iptables -t filter -F
- iptables -t filter -X
- echo - Vidage : [OK]
- #Creation d'une chaine
- iptables -N LOG_REJECT_SMTP
- iptables -A LOG_REJECT_SMTP -j LOG --log-prefix ' SMTP REJECT PAQUET : '
- iptables -A LOG_REJECT_SMTP -j DROP
- # Anti-Taiwanais
- iptables -t filter -A INPUT -i eth0 -s 61.64.128.0/17 -j LOG_REJECT_SMTP
- iptables -t filter -A INPUT -i eth0 -s 122.120.0.0/13 -j LOG_REJECT_SMTP
- iptables -t filter -A INPUT -i eth0 -s 168.95.0.0/16 -j LOG_REJECT_SMTP
- echo - Bloquer Taiwanais : [OK]
- # Ne pas casser les connexions etablies
- iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
- iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
- echo - Ne pas casser les connexions établies : [OK]
- # Autoriser la Supervision du serveur (SNMP)/ desactiver pour le moment
- #iptables -t filter -A INPUT -p tcp --dport 161 -s IP_SUPERVISION/32 -j ACCEPT
- #iptables -t filter -A INPUT -p udp --dport 161 -s IP_SUPERVISION/32 -j ACCEPT
- #echo - Autoriser Supervision : [OK]
- # Autoriser les requetes DNS, FTP (passif et actif), HTTP, NTP
- iptables -t filter -A OUTPUT -p tcp --dport 21 -j ACCEPT
- iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
- iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
- iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
- iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT
- echo - Autoriser les requetes DNS, FTP, HTTP : [OK]
- # Autoriser loopback
- iptables -t filter -A INPUT -i lo -j ACCEPT
- iptables -t filter -A OUTPUT -o lo -j ACCEPT
- echo - Autoriser loopback : [OK]
- # Autoriser ping
- iptables -t filter -A INPUT -p icmp -j ACCEPT
- iptables -t filter -A OUTPUT -p icmp -j ACCEPT
- echo - Autoriser ping : [OK]
- # HTTP
- iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
- iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
- echo - Autoriser serveur Apache : [OK]
- modprobe ip_conntrack_ftp
- iptables -t filter -A INPUT -p tcp --dport 21 -j ACCEPT
- iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
- echo - Autoriser serveur FTP : [OK]
- #DNS
- iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
- iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT
- echo - Autoriser serveur Bind : [OK]
- # Mail
- iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
- iptables -t filter -A INPUT -p tcp --dport 110 -j ACCEPT
- iptables -t filter -A INPUT -p tcp --dport 143 -j ACCEPT
- iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
- iptables -t filter -A OUTPUT -p tcp --dport 110 -j ACCEPT
- iptables -t filter -A OUTPUT -p tcp --dport 143 -j ACCEPT
- echo - Autoriser serveur Mail : [OK]
- # Autoriser SSH
- iptables -t filter -A INPUT -p tcp --dport 6060 -m recent --rcheck --seconds 60 --hitcount 2 --name SSH -j LOG --log-prefix "SSH REJECT"
- iptables -t filter -A INPUT -p tcp --dport 6060 -m recent --update --seconds 60 --hitcount 2 --name SSH -j DROP
- iptables -t filter -A INPUT -p tcp --dport 6060 -m state --state NEW -m recent --set --name SSH -j ACCEPT
- # Autoriser Webmin
- iptables -t filter -A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT
- echo - Autoriser Webmin : [OK]
Add Comment
Please, Sign In to add comment