Citation :
modprobe ip_conntrack_ftp
echo Module ip_conntrack_ftp chargé
modprobe ip_nat_ftp
echo Module ip_nat_ftp chargé
modprobe ip_nat_irc
echo Module ip_nat_irc chargé
modprobe iptable_nat
echo Module iptable_nat chargé
modprobe iptable_filter
echo Module iptable_filter chargé
modprobe iptable_mangle
echo Module iptable_mangle chargé
echo
iptables --flush
echo Table de règles vidées............................................[ OK ]
iptables -X
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
echo Fermeture de tous les ports.......................................[ OK ]
iptables -t nat -F
iptables -t nat -X
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
echo Ouverture des règles de nat.......................................[ OK ]
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
echo Activation du routage.............................................[ OK ]
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
echo Autorisations pour la boucle locale...............................[ OK ]
iptables -A INPUT -i ppp0 --protocol udp --source-port 53 -j ACCEPT
iptables -A OUTPUT -o ppp0 --protocol udp --destination-port 53 -j ACCEPT
iptables -A INPUT -i ppp0 --protocol tcp --source-port 53 -j ACCEPT
iptables -A OUTPUT -o ppp0 --protocol tcp --destination-port 53 -j ACCEPT
iptables -A FORWARD -i ppp0 -o eth0 --protocol udp --source-port 53 -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp0 --protocol udp --destination-port 53 -j ACCEPT
iptables -A FORWARD -i ppp0 -o eth0 --protocol tcp --source-port 53 -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp0 --protocol tcp --destination-port 53 -j ACCEPT
echo Autorisations pour les requêtes DNS externes......................[ OK ]
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les connections firewall/LAN...................[ OK ]
iptables -A FORWARD -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 80 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 443 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 80 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 443 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 80 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 443 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les requêtes HTTP..............................[ OK ]
iptables -A OUTPUT -p tcp --dport 1863 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 1863 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 1863 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 1863 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les requêtes MSN-Connections...................[ OK ]
iptables -A OUTPUT -p tcp --dport 6891:6900 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 6891:6900 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 6891:6900 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 6891:6900 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les requêtes MSN-Transferts....................[ OK ]
iptables -A OUTPUT -p tcp --dport 110 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 110 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 110 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 110 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les requêtes POP...............................[ OK ]
iptables -A OUTPUT -p tcp --dport 25 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 25 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 25 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 25 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les requêtes SMTP..............................[ OK ]
iptables -A OUTPUT -p tcp --dport 6667 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p udp --dport 6667 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 6667 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p udp --sport 6667 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 6667 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --dport 6667 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 6667 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --sport 6667 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les requêtes IRC-Port 6667.....................[ OK ]
iptables -A INPUT -p tcp --dport auth -j ACCEPT
iptables -A OUTPUT -p tcp --sport auth -j ACCEPT
echo Autorisations pour les requêtes d authentification-Port 113.......[ OK ]
iptables -A OUTPUT -p tcp --dport 21 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --sport 21 -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 21 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 21 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour les requêtes FTP...............................[ OK ]
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 20 -j DNAT --to-destination 192.168.0.2
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 21 -j DNAT --to-destination 192.168.0.2
iptables -A FORWARD -p tcp --dport 20 -i ppp0 -o eth0 -d 192.168.0.2 -m state --state ! INVALID -j ACCEPT
iptables -A FORWARD -p tcp --dport 21 -i ppp0 -o eth0 -d 192.168.0.2 -m state --state ! INVALID -j ACCEPT
#redirection port 21
iptables -A INPUT -p tcp --dport 8300:8399 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p udp --dport 8300:8399 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 8300:8399 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p udp --sport 8300:8399 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 8300:8399 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --dport 8300:8399 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 8300:8399 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --sport 8300:8399 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour Gunbound.......................................[ OK ]
iptables -A INPUT -p tcp --dport 4661 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 7890 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p udp --dport 7890 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p udp --dport 4672 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 2239 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 2290 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 4661 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 7890 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p udp --sport 7890 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p udp --sport 4672 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 2239 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 2290 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 4661:4662 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 4661:4662 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 7890 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHEd,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 7890 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --dport 7890 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --sport 7890 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --dport 4672 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p udp --sport 4672 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 2239 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 2239 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --dport 2290 -i eth0 -o ppp0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --sport 2290 -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
echo Autorisations pour Emule..........................................[ OK ]
echo
iptables -A PREROUTING -t nat -p tcp -d 193.253.160.3 --dport 4661 -j DNAT --to-dest 192.168.0.2:4661
echo Redirection du port tcp 4661 vers 192.168.0.2:4661
iptables -A PREROUTING -t nat -i eth0 -p tcp -m tcp --dport 7890 -j DNAT --to-destination 192.168.0.2:7890
echo Redirection du port tcp 7890 vers 192.168.0.2:7890
iptables -A PREROUTING -t nat -i eth0 -p udp -m udp --dport 7890 -j DNAT --to-destination 192.168.0.2:7890
echo Redirection du port udp 7890 vers 192.168.0.2:7890
iptables -A PREROUTING -t nat -p udp -d 193.253.160.3 --dport 4672 -j DNAT --to-dest 192.168.0.2:4672
echo Redirection du port udp 4672 vers 192.168.0.2:4672
iptables -t nat -I POSTROUTING --source 192.168.0.2 --jump MASQUERADE
echo Redirection des packets sortants
echo
echo 1 > /proc/sys/net/ipv4/ip_forward
echo Autorisation du système à effectuer le routage....................[ OK ]
echo
|