Il faut bien prendre conscience d'un truc, quand on a un serveur avec de l'ipv6, certains services comme sshd vont écouter en ipv6 et en ipv4
Si vous avez restreint l'acces au port SSH à certaines ips de confiances, il faut aussi faire l'opération avec ip6tables sinon vous êtes à poil en ipv6
Ce sont deux stacks complètement indépendantes
Description du format d'iptables-save
"This contains a few comments starting with a # sign. Each table is marked like *, for example *mangle. Then within each table we have the chain specifications and rules. A chain specification looks like : [:]. The chain-name may be for example PREROUTING, the policy is described previously and can, for example, be ACCEPT. Finally the packet-counter and byte-counters are the same counters as in the output from iptables -L -v. Finally, each table declaration ends in a COMMIT keyword. The COMMIT keyword tells us that at this point we should commit all rules currently in the pipeline to kernel. "
Le schema dans cet article est vraiment clair (ce qui est rare pour un schema iptables)
une rule rsyslog
un logrotate
+ commentaire à la regle iptable
Franchement pas d'accord avec lui t_t
Bon ya aussi de bons conseil dans l'article, alors je lui pardonne !
"Consider a situation where your INPUT chain contains quite a few rules allowing traffic, and you’ve set the default policy to DROP. Later on, another administrator logs into the server and flushes the rules (which isn’t a good practice, either). I’ve met quite a few good systems administrators who are unaware of the default policy for iptables chains. Your server will be completely inaccessible immediately. All of the packets will be dropped since they match the default policy in the chain."
Pas simple : "ulogd" un plugin userspace pour iptables va sortir un output en JSON. Logstash récupère derriere et envoie à elasticsearch. Kibana peut afficher.
Au final un dashboard qui résume le trafic.
+ http://www.netfilter.org/projects/ulogd/index.html
Via skunnyk
Très bon article qui explique le fonctionnement d'iptables
[Summary, full note in Shaarli]
Règles FORWARD et NAT avec iptables (doc RHEL). Voir aussi http://www.admin-debian.com/securite/iptables-et-netfilter/
TLDR :
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport EXTERNAL_PORT -j DNAT --to INTERNAL_IP:INTERNAL_PORT
iptables -L
iptables -D fail2ban-SSH -s XXX.XXX.XXX.XXX -j DROP