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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#!/bin/bash
#START
echo 0 > /proc/sys/net/ipv4/ip_forward
#Supprimer et remplacer la table Filter Existante
iptables -t filter -F
iptables -t filter -X
#Regles par défaut
iptables -t filter -P INPUT DROP
iptables -t filter -P OUTPUT DROP
iptables -t filter -P FORWARD DROP
#Autoriser Loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -t filter -A OUTPUT -o lo -j ACCEPT
#Autoriser Ping sur FW
iptables -t filter -A INPUT -p icmp -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -j ACCEPT
#Update Fw
iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#SSH Clien LAN
iptables -t filter -A INPUT -s $IP_CLIENT -p tcp --dport 22 -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#CT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#Allow Net
iptables -t filter -A POSTROUTING -o $INT_WAN -j MASQUERADE
iptables -t filter -A FORWARD -p tcp -s $INT_LAN --dport 80 -j ACCEPT
iptables -t filter -A FORWARD -p tcp -s $INT_LAN --dport 8080 -j ACCEPT
iptables -t filter -A FORWARD -p udp -s $INT_LAN --dport 53 -j ACCEPT
iptables -t filter -A FORWARD -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
#Ping Uniquement Lan
iptables -t filter -A INPUT -s $INT_LAN -p icmp -j ACCEPT
iptables -t filter -A OUTPUT -o $INT_LAN -p icmp -j ACCEPT
#Client Admin
iptables -t filter -A INPUT -s $IP_CLIENT -p tcp --dport 22 -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Client consulte site web
iptables -t nat -A PREROUTING -d $IP_WAN -i $INT_WAN -p tcp --dport 80 -j DNAT --to $IP_WEBSERVER
iptables -t filter -A FORWARD -p tcp -m state --state NEW,ESTABLISHED,RELATED --dport 80 -i $INT_WAN -j ACCEPT
#WAN acces to FTP
iptables -t nat -A PREROUTING -d $IP_WAN -i $INT_WAN -p tcp --dport 20 -j DNAT --to $IP_FTP
iptables -t filter -A FORWARD-p tcp -m state --state NEW,ESTABLISHED,RELATED --dport 20 -i $INT_WAN -j ACCEPT
iptables -t nat -A PREROUTING -d $IP_WAN -i $INT_WAN -p tcp --dport 21 -j DNAT --to $IP_FTP
iptables -t filter -A FORWARD -p tcp -m state --state NEW,ESTABLISHED,RELATED --dport 21 -i $INT_WAN -j ACCEPT
###VLAN###
#VLAN 10-20-30 sur net
iptables -t nat -A POSTROUTING -o $INT_WAN -j MASQUERADE
iptables -t filter -A FORWARD -p tcp -s $SUB_10_TO_30 --dport 80 -j ACCEPT
iptables -t filter -A FORWARD -p tcp -s $SUB_10_TO_30 --dport 8080 -j ACCEPT
iptables -t filter -A FORWARD -p udp -s $SUB_10_TO_30 --dport 53 -j ACCEPT
iptables -t filter -A FORWARD -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
#Ping en entrée
iptables -t filter -A INPUT -s $SUB_10_TO_30 -p icmp -j ACCEPT
#VLAN 10 admins
iptables -t filter -A INPUT -s $SUB_VLAN100 -p tcp --dport 22 -j ACCEPT
iptables -t filter -A OUTPUT -p all -m state --state ESTABLISHED,RELATED -j ACCEPT
#VLAN 10 to Others
iptables -t filter -A FORWARD -p all -s $SUB_VLAN10 -d $SUB_10_TO_30 -j ACCEPT
#VLAN 20 to 30
iptables -t filter -A FORWARD -p all -s $SUB_BLAN20 -d $SUB_VLAN30 -j ACCEPT
#END
echo 1 > /proc/sys/net/ipv4/ip_forward |
Partager