Projet

Général

Profil

IPTables » Historique » Version 26

Version 25 (Laurent GUERBY, 25/08/2014 19:32) → Version 26/31 (Laurent GUERBY, 25/08/2014 19:35)

{{>toc}}

h1. IPTables

h2. iptables links

* http://www.bortzmeyer.org/dns-netfilter-u32.html
* http://www.stearns.org/doc/iptables-u32.current.html
* http://ebtables.sourceforge.net/br_fw_ia/PacketFlow.png
* http://ebtables.sourceforge.net/
* http://www.inetdoc.net/guides/iptables-tutorial/traversingoftables.html
* http://upload.wikimedia.org/wikipedia/commons/3/37/Netfilter-packet-flow.svg
* https://en.wikipedia.org/wiki/List_of_router_or_firewall_distributions

DHCP ?
sysctl -w net.bridge.bridge-nf-call-iptables=1
sysctl -w net.bridge.bridge-nf-call-ip6tables=1
iptables -A INPUT -p udp --sport 68 --dport 67 -j DROP

https://bugzilla.redhat.com/show_bug.cgi?id=512206

* libnml
** http://www.spinics.net/lists/netfilter/msg52868.html
** http://1984.lsi.us.es/~pablo/docs/spae.pdf

h2. iptables hairpin

Hair pin / hairpin / hairpinning / NAT reflection

http://serverfault.com/questions/205040/accessing-the-dnatted-webserver-from-inside-the-lan

Avec :
* PUB_IP = ip publique sur le host et interface eth0
* LXC_IP = l'ip privee de la VM dans 192.168.100.0/24
* PORT_LIST = 80,443 (et d'autres) la liste des ports a transferer a la VM

<pre>
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -d ${PUB_IP}/32 -p tcp -m multiport --dports ${PORT_LIST} -j DNAT --to-destination ${LXC_IP}
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -d ${LXC_IP}/32 -p tcp -m multiport --dports ${PORT_LIST} -j MASQUERADE
iptables -t nat -A OUTPUT -d ${PUB_IP} -p tcp -m multiport --dports ${PORT_LIST} -j DNAT --to-destination ${LXC_IP}
</pre>

* ligne 1 : pour que la VM puisse acceder a l'internet il faut le NAT
* ligne 2 : redirection des ports de l'ip publique vers la VM
* ligne 3 : si la VM veut parler a l'IP publique il faut faire un reflection NAT vers la VM
* ligne 4 : si le host veut parler a l'IP publique il faut diriger vers la VM



h1. ebtables

ebtables -A FORWARD -d ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff -p IPv4 --ip-prot udp --ip-dport 67:68 -j DROP

* http://serverfault.com/questions/284290/two-dhcp-servers-block-clients-for-one-of-them

ebtables -A INPUT --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-source-port 67:68 -j DROP
ebtables -A INPUT --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-destination-port 67:68 -j DROP
ebtables -A FORWARD --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-destination-port 67:68 -j DROP
ebtables -A FORWARD --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-source-port 67:68 -j DROP

h1. ipset

http://ipset.netfilter.org/