Iptables

iptables e' il filtro/firewall di Linux. Ecco alcuni comandi da conoscere.

Lista regole

 iptables -S

 -P INPUT DROP
 -P FORWARD DROP
 -P OUTPUT ACCEPT
 -N f2b-apache-noscript
 -N f2b-sshd
 -N sshguard
 ...

Avere la lista numerata:

 iptables -L --line-numbers

 Chain INPUT (policy DROP)
 num  target     prot opt source               destination
 1    f2b-apache-noscript  tcp  --  anywhere             anywhere             multiport dports http,https
 2    f2b-sshd   tcp  --  anywhere             anywhere             multiport dports ssh
 3    ufw-before-logging-input  all  --  anywhere             anywhere
 4    ufw-before-input  all  --  anywhere             anywhere
 5    ufw-after-input  all  --  anywhere             anywhere
 6    ufw-after-logging-input  all  --  anywhere             anywhere
 7    ufw-reject-input  all  --  anywhere             anywhere
 8    ufw-track-input  all  --  anywhere             anywhere
 9    sshguard   all  --  anywhere             anywhere 

 Chain FORWARD (policy DROP)
 num  target     prot opt source               destination
 1    ufw-before-logging-forward  all  --  anywhere             anywhere
 2    ufw-before-forward  all  --  anywhere             anywhere
 ...

Cancellare una regola:

 iptables -D INPUT 3

Modificare l'ordine delle regole

Esportare tutto con:

  iptables-save > /tmp/iptables.txt

Modificare l'ordine delle righe che ci interessa nel file iptables.txt, salvare il file e poi importarlo:

 iptables-restore < /tmp/iptables.txt