Forum Linux.général Iptables et Firewall sur WRT54G/OpenWRT

Posté par .
Étiquettes :
1
23
fév.
2011

Bonjour,

Pour sécuriser un peu mon WRT54G avec son OpenWRT, j'ai cela dans mon /etc/firewall.user:

# This file is interpreted as shell script.
# Put your custom iptables rules here, they will
# be executed with each firewall (re-)start.
iptables -A input_wan -p tcp --dport 32 -m state --state NEW -m recent --name ATTACKER_SSH --rsource --update --seconds 600 --hitcount 2 -j DROP
iptables -A input_wan -p tcp --dport 32 -m state --state NEW -m recent --name ATTACKER_SSH --rsource --set
iptables -A input_wan -p tcp --dport 32 -m state --state NEW -j ACCEPT

Quand, je fais un iptables -L input_wan, j'ai le résultat suivant:

Chain input_wan (1 references)
target prot opt source destination 
DROP tcp -- anywhere anywhere tcp dpt:32 state NEW recent: UPDATE seconds: 600 hit_count: 2 name: ATTACKER_SSH side: source 
 tcp -- anywhere anywhere tcp dpt:32 state NEW recent: SET name: ATTACKER_SSH side: source 
ACCEPT tcp -- anywhere anywhere tcp dpt:32 state NEW 

Ma question, car j'en ai une, c'est comment ça marche ? Cette règle ne s'applique pas sur mon LAN mais uniquement sur mon WAN. Pourtant, je ne vois pas mention ceci dans les règles.

Merci et à bientôt.

  • # grep

    Posté par (site web personnel) . Évalué à 1.

    Peut être un grep input_wan <fichier_du_pare_feu>

    Système - Réseau - Sécurité Open Source - Ouvert à de nouvelles opportunités

  • # je dois etre debile car j'ai pas compris la question

    Posté par . Évalué à 1.

    dans ton fichier /etc/firewall.user, tu as 3 regles qui s'appliquent à la chaine "input_wan"

    ensuite quand tu fais un iptables -L input_wan ca t'affiche bien les trois regles en provenance de /etc/firewall.user

    je ne vois donc pas ce qui te pose souci ?

    • [^] # Re: je dois etre debile car j'ai pas compris la question

      Posté par . Évalué à 0.

      En fait, ce que je comprend pas c'est pourquoi ces règles ne s'appliquent qu'au trafic WAN.

      Quand, j'essaye d'accéder au serveur SSH depuis mon réseau local (plus de 2 fois), j'ai pas de problème. Quand, j'essaye d'accéder au serveur SSH depuis l’extérieur (plus de 2 fois), je suis dégagé.

      C'est bien ce que je veux. Cependant, je n'arrive pas à comprendre ce qui indique dans la règle que cela ne concerne pas mon réseau local.

      Voilà. J'espère que c'est plus clair maintenant.

      • [^] # option -v

        Posté par (site web personnel) . Évalué à 1.

        Tout est dans le titre.

        Système - Réseau - Sécurité Open Source - Ouvert à de nouvelles opportunités

      • [^] # Re: je dois etre debile car j'ai pas compris la question

        Posté par . Évalué à 2.

        la reponse se trouve dans : -A input_wan

        en effet, les regles que tu definis dans le fichier firewall.users s'appliquent sur cette chaine.

        elle doit etre definie ailleurs, dans la config par defaut du parefeu.

        il ne te reste plus qu'à chercher dans la config comment est definie la chaine input_wan

        • [^] # Re: je dois etre debile car j'ai pas compris la question

          Posté par . Évalué à 0.

          La commande iptables -L -v m'a permis de mieux comprendre. Merci.

          • [^] # Re: je dois etre debile car j'ai pas compris la question

            Posté par (site web personnel) . Évalué à 1.

            Quel est le résultat de celle-ci? Cela pourrait servir à d'autres personnes.

            Système - Réseau - Sécurité Open Source - Ouvert à de nouvelles opportunités

            • [^] # Re: je dois etre debile car j'ai pas compris la question

              Posté par . Évalué à 0.

              Voici la sortie complète:

              root@OpenWrt:~# iptables -L -v 
              Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
               pkts bytes target prot opt in out source destination 
              15863 1548K ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED 
               0 0 ACCEPT all -- lo any anywhere anywhere 
               5989 310K syn_flood tcp -- any any anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN 
              24898 1501K input_rule all -- any any anywhere anywhere 
              24898 1501K input all -- any any anywhere anywhere 
              Chain FORWARD (policy DROP 0 packets, 0 bytes)
               pkts bytes target prot opt in out source destination 
              1928K 1544M zone_wan_MSSFIX all -- any any anywhere anywhere 
              1911K 1544M ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED 
              17362 886K forwarding_rule all -- any any anywhere anywhere 
              17362 886K forward all -- any any anywhere anywhere 
               0 0 reject all -- any any anywhere anywhere 
              Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
               pkts bytes target prot opt in out source destination 
              26899 4478K ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED 
               0 0 ACCEPT all -- any lo anywhere anywhere 
               7633 517K output_rule all -- any any anywhere anywhere 
               7633 517K output all -- any any anywhere anywhere 
              Chain forward (1 references)
               pkts bytes target prot opt in out source destination 
              17362 886K zone_lan_forward all -- br-lan any anywhere anywhere 
               0 0 zone_wan_forward all -- eth0.1 any anywhere anywhere 
              Chain forwarding_lan (1 references)
               pkts bytes target prot opt in out source destination 
              Chain forwarding_rule (1 references)
               pkts bytes target prot opt in out source destination 
              Chain forwarding_wan (1 references)
               pkts bytes target prot opt in out source destination 
              Chain input (1 references)
               pkts bytes target prot opt in out source destination 
              18098 1154K zone_lan all -- br-lan any anywhere anywhere 
               6800 347K zone_wan all -- eth0.1 any anywhere anywhere 
              Chain input_lan (1 references)
               pkts bytes target prot opt in out source destination 
              Chain input_rule (1 references)
               pkts bytes target prot opt in out source destination 
              Chain input_wan (1 references)
               pkts bytes target prot opt in out source destination 
               0 0 DROP tcp -- any any anywhere anywhere tcp dpt:32 state NEW recent: UPDATE seconds: 600 hit_count: 2 name: ATTACKER_SSH side: source 
               0 0 tcp -- any any anywhere anywhere tcp dpt:32 state NEW recent: SET name: ATTACKER_SSH side: source 
               0 0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:32 state NEW 
              Chain output (1 references)
               pkts bytes target prot opt in out source destination 
               7633 517K zone_lan_ACCEPT all -- any any anywhere anywhere 
               7559 493K zone_wan_ACCEPT all -- any any anywhere anywhere 
              Chain output_rule (1 references)
               pkts bytes target prot opt in out source destination 
              Chain reject (5 references)
               pkts bytes target prot opt in out source destination 
               6041 316K REJECT tcp -- any any anywhere anywhere reject-with tcp-reset 
               37 8430 REJECT all -- any any anywhere anywhere reject-with icmp-port-unreachable 
              Chain syn_flood (1 references)
               pkts bytes target prot opt in out source destination 
               5989 310K RETURN tcp -- any any anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 25/sec burst 50 
               0 0 DROP all -- any any anywhere anywhere 
              Chain zone_lan (1 references)
               pkts bytes target prot opt in out source destination 
              18098 1154K input_lan all -- any any anywhere anywhere 
              18098 1154K zone_lan_ACCEPT all -- any any anywhere anywhere 
              Chain zone_lan_ACCEPT (2 references)
               pkts bytes target prot opt in out source destination 
              18098 1154K ACCEPT all -- br-lan any anywhere anywhere 
               74 24127 ACCEPT all -- any br-lan anywhere anywhere 
              Chain zone_lan_DROP (0 references)
               pkts bytes target prot opt in out source destination 
               0 0 DROP all -- br-lan any anywhere anywhere 
               0 0 DROP all -- any br-lan anywhere anywhere 
              Chain zone_lan_MSSFIX (0 references)
               pkts bytes target prot opt in out source destination 
               0 0 TCPMSS tcp -- any br-lan anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU 
              Chain zone_lan_REJECT (1 references)
               pkts bytes target prot opt in out source destination 
               0 0 reject all -- br-lan any anywhere anywhere 
               0 0 reject all -- any br-lan anywhere anywhere 
              Chain zone_lan_forward (1 references)
               pkts bytes target prot opt in out source destination 
              17362 886K zone_wan_ACCEPT all -- any any anywhere anywhere 
               0 0 forwarding_lan all -- any any anywhere anywhere 
               0 0 zone_lan_REJECT all -- any any anywhere anywhere 
              Chain zone_wan (1 references)
               pkts bytes target prot opt in out source destination 
               1 328 ACCEPT udp -- any any anywhere anywhere udp dpt:68 
               721 22625 ACCEPT icmp -- any any anywhere anywhere icmp echo-request 
               6078 324K input_wan all -- any any anywhere anywhere 
               6078 324K zone_wan_REJECT all -- any any anywhere anywhere 
              Chain zone_wan_ACCEPT (2 references)
               pkts bytes target prot opt in out source destination 
               0 0 ACCEPT all -- eth0.1 any anywhere anywhere 
              24921 1380K ACCEPT all -- any eth0.1 anywhere anywhere 
              Chain zone_wan_DROP (0 references)
               pkts bytes target prot opt in out source destination 
               0 0 DROP all -- eth0.1 any anywhere anywhere 
               0 0 DROP all -- any eth0.1 anywhere anywhere 
              Chain zone_wan_MSSFIX (1 references)
               pkts bytes target prot opt in out source destination 
              17191 884K TCPMSS tcp -- any eth0.1 anywhere anywhere tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU 
              Chain zone_wan_REJECT (2 references)
               pkts bytes target prot opt in out source destination 
               6078 324K reject all -- eth0.1 any anywhere anywhere 
               0 0 reject all -- any eth0.1 anywhere anywhere 
              Chain zone_wan_forward (1 references)
               pkts bytes target prot opt in out source destination 
               0 0 forwarding_wan all -- any any anywhere anywhere 
               0 0 zone_wan_REJECT all -- any any anywhere anywhere
              

Suivre le flux des commentaires

Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.