# Bloquer tout en entrée, autoriser en sortieufwdefaultdenyincoming
ufwdefaultallowoutgoing
# Vérifierufwstatusverbose
3. Autoriser des services
# Par nom de serviceufwallowssh
ufwallowhttp
ufwallowhttps
# Ou par portufwallow22/tcp
ufwallow80/tcp
ufwallow443/tcp
# Service avec profil d'applicationufwallow'Nginx Full'ufwallow'OpenSSH'# Lister les profils disponiblesufwapplist
4. Règles par port
# Port TCPufwallow8080/tcp
# Port UDPufwallow53/udp
# Plage de portsufwallow3000:3100/tcp
# Port TCP et UDPufwallow1194
5. Règles par IP source
# Autoriser une IPufwallowfrom192.168.1.100
# Autoriser un réseauufwallowfrom192.168.1.0/24
# IP + port spécifiqueufwallowfrom192.168.1.0/24toanyport22# IP + serviceufwallowfrom192.168.1.0/24toanyport3306prototcp
# Bloquer une IPufwdenyfrom10.0.0.50
6. Règles vers une interface
# Autoriser sur une interface spécifiqueufwallowinoneth0toanyport80# Autoriser entre interfacesufwallowinoneth1outoneth0
7. Supprimer des règles
# Par numéroufwstatusnumbered
ufwdelete3# Par règleufwdeleteallow8080/tcp
ufwdeleteallowfrom192.168.1.0/24
8. Règles avancées
# Limiter les connexions (protection brute-force)ufwlimitssh
# Équivalent à: max 6 connexions en 30 secondes# Loggingufwloggingon
ufwloggingmedium# off, low, medium, high, full# Voir les logstail-f/var/log/ufw.log