Gestion de règle iptable : Liste, suppression, ajout.
1/ Liste des règles Iptables.
root@server01lxc:/home/admin# iptables -t nat -L --line-numbers -n Chain PREROUTING (policy ACCEPT) num target prot opt source destination 1 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:10.0.3.11:8080 2 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3000 to:10.0.3.12:3000 3 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3001 to:10.0.3.12:3001 4 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:9001 to:10.0.3.12:9001 5 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:30000 to:10.0.3.13:30000 6 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:30000 to:10.0.3.13:30000 7 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6900 to:10.0.3.14:6900 8 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6900 to:10.0.3.14:6900 9 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6697 to:10.0.3.14:6697 10 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6697 to:10.0.3.14:6697 11 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6667 to:10.0.3.14:6667 12 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6667 to:10.0.3.14:6667 13 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:81 to:10.0.3.15:8080 Chain INPUT (policy ACCEPT) num target prot opt source destination Chain OUTPUT (policy ACCEPT) num target prot opt source destination Chain POSTROUTING (policy ACCEPT) num target prot opt source destination 1 MASQUERADE all -- 10.0.3.0/24 !10.0.3.0/24
2/ Suppression d’une règle iptable.
root@server01lxc:/home/admin# iptables -t nat -D PREROUTING 13
3/ Vérification.
root@server01lxc:/home/admin# iptables -t nat -L --line-numbers -n Chain PREROUTING (policy ACCEPT) num target prot opt source destination 1 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:10.0.3.11:8080 2 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3000 to:10.0.3.12:3000 3 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3001 to:10.0.3.12:3001 4 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:9001 to:10.0.3.12:9001 5 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:30000 to:10.0.3.13:30000 6 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:30000 to:10.0.3.13:30000 7 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6900 to:10.0.3.14:6900 8 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6900 to:10.0.3.14:6900 9 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6697 to:10.0.3.14:6697 10 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6697 to:10.0.3.14:6697 11 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6667 to:10.0.3.14:6667 12 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6667 to:10.0.3.14:6667 Chain INPUT (policy ACCEPT) num target prot opt source destination Chain OUTPUT (policy ACCEPT) num target prot opt source destination Chain POSTROUTING (policy ACCEPT) num target prot opt source destination 1 MASQUERADE all -- 10.0.3.0/24 !10.0.3.0/24
4/ Ajout d’une règle.
root@server01lxc:/home/admin# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 81 -j DNAT --to-destination 10.0.3.15:8080
5/ Vérification.
root@server01lxc:/home/admin# iptables -t nat -L --line-numbers -n Chain PREROUTING (policy ACCEPT) num target prot opt source destination 1 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:10.0.3.11:8080 2 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3000 to:10.0.3.12:3000 3 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3001 to:10.0.3.12:3001 4 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:9001 to:10.0.3.12:9001 5 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:30000 to:10.0.3.13:30000 6 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:30000 to:10.0.3.13:30000 7 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6900 to:10.0.3.14:6900 8 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6900 to:10.0.3.14:6900 9 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6697 to:10.0.3.14:6697 10 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6697 to:10.0.3.14:6697 11 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6667 to:10.0.3.14:6667 12 DNAT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:6667 to:10.0.3.14:6667 13 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:81 to:10.0.3.15:8080 Chain INPUT (policy ACCEPT) num target prot opt source destination Chain OUTPUT (policy ACCEPT) num target prot opt source destination Chain POSTROUTING (policy ACCEPT) num target prot opt source destination 1 MASQUERADE all -- 10.0.3.0/24 !10.0.3.0/24
6/ Lien.
http://lubos.rendek.org/remove-all-iptables-prerouting-nat-rules/
Comments are closed, but trackbacks and pingbacks are open.