wan-lan-firewall-rules.sh
Application of iptables firewall rules to secure WAN and LAN interfaces.
The RTL8198D handles hardware routing, but iptables rules apply to the CPU. eth0 is typically the WAN port, br-lan the LAN ports. This script adds rules in memory; for persistence, integrate them into /etc/firewall.user or via UCI. Always test SSH connection before locking rules.
wan-lan-firewall-rules.sh
#!/bin/sh
# Configuration Firewall personnalisée pour BPI-RT2 via iptables/uci
# Bloquer l'accès SSH depuis WAN (sécurité de base)
iptables -I INPUT -i eth0 -p tcp --dport 22 -j DROP
# Autoriser le ping depuis LAN uniquement
iptables -I INPUT -i br-lan -p icmp --icmp-type echo-request -j ACCEPT
iptables -I INPUT -p icmp --icmp-type echo-request -j DROP
# Limiter le taux de connexion pour prévenir les attaques DoS simples
iptables -I INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j ACCEPT
# Sauvegarde des règles pour persistance
/etc/init.d/firewall restart
# Vérification
iptables -L -v -n