Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format
PDF et la grise au format ODT →
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
doc:reseau:iptables-pare-feu-pour-une-passerelle [16/11/2014 07:24] Hypathie [Les règles du pare-feu pas à pas] |
doc:reseau:iptables-pare-feu-pour-une-passerelle [16/11/2014 07:39] Hypathie [Les règles du pare-feu pas à pas] |
||
---|---|---|---|
Ligne 354: | Ligne 354: | ||
... | ... | ||
- | /sbin/iptables -t filter -A FORWARD -i eth1 -o eth0 -s 192.168.1.0/24 -d 0.0.0.0/0 -p\ | + | iptables -t filter -A FORWARD -i eth1 -o eth0 -s 192.168.1.0/24 -d 0.0.0.0/0 -p\ |
tcp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT | tcp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT | ||
- | /sbin/iptables -t filter -A FORWARD -i eth0 -o eth1 -s 0.0.0.0/0 -d 192.168.1.0/24 -p\ | + | iptables -t filter -A FORWARD -i eth0 -o eth1 -s 0.0.0.0/0 -d 192.168.1.0/24 -p\ |
tcp -m state --state ESTABLISHED,RELATED -j ACCEPT | tcp -m state --state ESTABLISHED,RELATED -j ACCEPT | ||
/sbin/iptables -t filter -A FORWARD -p icmp -j ACCEPT | /sbin/iptables -t filter -A FORWARD -p icmp -j ACCEPT | ||
+ | |||
+ | iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | ||
</code> | </code> | ||
- | <note> | + | <note tip> |
- | Ou sans suivi de connexion :\\ | + | **__Quelques exlications :__** |
+ | |||
+ | * __Sans suivi de connexion__ : | ||
+ | |||
+ | iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT | ||
+ | iptables -A FORWARD -o eth1 -i eth0 -j ACCEPT | ||
+ | |||
+ | > On autorise tout passage de eth1 à eth0 et de eth0 à eth1 | ||
+ | |||
+ | * __Avec suivi de connexion__ : | ||
+ | |||
+ | iptables -t filter -A FORWARD -i eth1 -o eth0 -s 192.168.1.0/24 -d 0.0.0.0/0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT | ||
+ | iptables -t filter -A FORWARD -i eth0 -o eth1 -s 0.0.0.0/0 -d 192.168.1.0/24 -m state --state ESTABLISHED,RELATED -j ACCEPT | ||
- | iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT\\ | + | > On autorise tout passage avec suivi de connexion de eth1 à eth0 et inversement, en précisant les sous-réseaux. |
- | iptables -A FORWARD -o eth1 -i eth0 -j ACCEPT | + | |
</note> | </note> | ||
* On vérifie si le ping fonctionne de la machine A vers la machine B : | * On vérifie si le ping fonctionne de la machine A vers la machine B : | ||
Ligne 448: | Ligne 461: | ||
#On garde nos règles concernant le DROP sur FORWARD (FILTER) | #On garde nos règles concernant le DROP sur FORWARD (FILTER) | ||
#mais on oublie pas eth1 ! | #mais on oublie pas eth1 ! | ||
- | iptables -t filter -A FORWARD -i eth1 -o eth0 -s 192.168.1.0/24\ | + | /sbin/iptables -t filter -A FORWARD -i eth1 -o eth0 -s 192.168.1.0/24 -d 0.0.0.0/0 -p\ |
- | -d 0.0.0.0/0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT | + | tcp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT |
- | iptables -t filter -A FORWARD -i eth0 -o eth1 -s 0.0.0.0/0\ | + | /sbin/iptables -t filter -A FORWARD -i eth0 -o eth1 -s 0.0.0.0/0 -d 192.168.1.0/24 -p\ |
- | -d 192.168.1.0/24 -m state --state ESTABLISHED,RELATED -j ACCEPT | + | tcp -m state --state ESTABLISHED,RELATED -j ACCEPT |
iptables -t filter -A INPUT -p icmp -i eth0 -m conntrack\ | iptables -t filter -A INPUT -p icmp -i eth0 -m conntrack\ |