Projet

Général

Profil

IPTables » Historique » Version 28

Laurent GUERBY, 25/08/2014 19:39

1 1 Laurent GUERBY
{{>toc}}
2 1 Laurent GUERBY
3 1 Laurent GUERBY
h1. IPTables
4 1 Laurent GUERBY
5 22 Laurent GUERBY
h2. iptables links
6 22 Laurent GUERBY
7 1 Laurent GUERBY
* http://www.bortzmeyer.org/dns-netfilter-u32.html
8 1 Laurent GUERBY
* http://www.stearns.org/doc/iptables-u32.current.html
9 1 Laurent GUERBY
* http://ebtables.sourceforge.net/br_fw_ia/PacketFlow.png
10 1 Laurent GUERBY
* http://ebtables.sourceforge.net/
11 6 Laurent GUERBY
* http://www.inetdoc.net/guides/iptables-tutorial/traversingoftables.html
12 11 Laurent GUERBY
* http://upload.wikimedia.org/wikipedia/commons/3/37/Netfilter-packet-flow.svg
13 10 Laurent GUERBY
* https://en.wikipedia.org/wiki/List_of_router_or_firewall_distributions
14 2 Laurent GUERBY
15 2 Laurent GUERBY
DHCP ?
16 3 Laurent GUERBY
sysctl -w net.bridge.bridge-nf-call-iptables=1 
17 3 Laurent GUERBY
sysctl -w net.bridge.bridge-nf-call-ip6tables=1 
18 3 Laurent GUERBY
iptables -A INPUT -p udp --sport 68 --dport 67 -j DROP
19 2 Laurent GUERBY
20 4 Laurent GUERBY
https://bugzilla.redhat.com/show_bug.cgi?id=512206
21 4 Laurent GUERBY
22 7 Laurent GUERBY
* libnml
23 7 Laurent GUERBY
** http://www.spinics.net/lists/netfilter/msg52868.html
24 7 Laurent GUERBY
** http://1984.lsi.us.es/~pablo/docs/spae.pdf
25 22 Laurent GUERBY
26 28 Laurent GUERBY
Ne pas oublier 
27 28 Laurent GUERBY
28 28 Laurent GUERBY
<pre>
29 28 Laurent GUERBY
conntrack -F
30 28 Laurent GUERBY
</pre>
31 28 Laurent GUERBY
32 28 Laurent GUERBY
Apres chaque changement de regles.
33 28 Laurent GUERBY
34 22 Laurent GUERBY
h2. iptables hairpin
35 22 Laurent GUERBY
36 22 Laurent GUERBY
Hair pin / hairpin / hairpinning / NAT reflection
37 22 Laurent GUERBY
38 22 Laurent GUERBY
http://serverfault.com/questions/205040/accessing-the-dnatted-webserver-from-inside-the-lan
39 22 Laurent GUERBY
40 25 Laurent GUERBY
Avec :
41 25 Laurent GUERBY
* PUB_IP = ip publique sur le host et interface eth0
42 25 Laurent GUERBY
* LXC_IP = l'ip privee de la VM dans 192.168.100.0/24
43 25 Laurent GUERBY
* PORT_LIST = 80,443 (et d'autres) la liste des ports a transferer a la VM
44 22 Laurent GUERBY
45 1 Laurent GUERBY
<pre>
46 24 Laurent GUERBY
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
47 25 Laurent GUERBY
iptables -t nat -A PREROUTING -d ${PUB_IP}/32  -p tcp -m multiport --dports ${PORT_LIST} -j DNAT --to-destination ${LXC_IP}
48 24 Laurent GUERBY
iptables -t nat -A POSTROUTING -s 192.168.100.0/24 -d ${LXC_IP}/32  -p tcp -m multiport --dports ${PORT_LIST} -j MASQUERADE
49 24 Laurent GUERBY
iptables -t nat -A OUTPUT -d ${PUB_IP} -p tcp -m multiport --dports ${PORT_LIST}  -j DNAT --to-destination ${LXC_IP}
50 22 Laurent GUERBY
</pre>
51 7 Laurent GUERBY
52 26 Laurent GUERBY
* ligne 1 : pour que la VM puisse acceder a l'internet il faut le NAT
53 26 Laurent GUERBY
* ligne 2 : redirection des ports de l'ip publique vers la VM
54 26 Laurent GUERBY
* ligne 3 : si la VM veut parler a l'IP publique il faut faire un reflection NAT vers la VM
55 27 Laurent GUERBY
* ligne 4 : si le host veut parler a l'IP publique sur un port géré par la VM il faut diriger vers la VM
56 26 Laurent GUERBY
57 2 Laurent GUERBY
h1. ebtables
58 2 Laurent GUERBY
59 9 Laurent GUERBY
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
60 9 Laurent GUERBY
61 2 Laurent GUERBY
* http://serverfault.com/questions/284290/two-dhcp-servers-block-clients-for-one-of-them
62 5 Laurent GUERBY
63 5 Laurent GUERBY
ebtables -A INPUT --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-source-port 67:68 -j DROP
64 5 Laurent GUERBY
ebtables -A INPUT --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-destination-port 67:68 -j DROP
65 5 Laurent GUERBY
ebtables -A FORWARD --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-destination-port 67:68 -j DROP
66 5 Laurent GUERBY
ebtables -A FORWARD --in-interface br0 --protocol ipv4 --ip-protocol udp --ip-source-port 67:68 -j DROP
67 8 Laurent GUERBY
68 8 Laurent GUERBY
h1. ipset
69 8 Laurent GUERBY
70 8 Laurent GUERBY
http://ipset.netfilter.org/