[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Multiple discrete IP match rule - iptables



Le jeudi 01 avril 2004 à 04h25 (-0300), Alano Stolf écrivait :
> I have not found any reference on how to specify more than one IP
> (discrete IPs, not a range) in an iptables rule.
> For example, how can I log only the access to SMTP servers that are not
> the ones I may allow.
> For instance, a rule like this should be fine:
> iptables -A FORWARD -p tcp -d ! (IP_of_MySMTP_1 IP_of_MySMTP_2) --dport 25
> -j LOG --log-prefix "Access to suspicious SMTP: "

One way is to use a chain:

  iptables -N MySMTPCheck
  iptables -A MySMTPCheck -d IP_of_MySMTP_1 -j RETURN
  iptables -A MySMTPCheck -d IP_of_MySMTP_2 -j RETURN
  iptables -A MySMTPCheck -d ... -j RETURN
  iptables -A MySMTPCheck -j LOG --log-prefix "Access to suspicious SMTP: "

  iptables -A FORWARD -p tcp -m tcp --dport 25 -m state --state NEW \
                      --syn -j MySMTPCheck

Regards,
-- 
J.C. "プログフ" ANDRÉ <jean-christophe.andre@auf.org> http://www.vn.refer.org/
Coordonnateur technique régional / Associé technologie projet Reflets (CODA)
Agence universitaire de la Francophonie (AuF) / Bureau Asie-Pacifique (BAP)
Adresse postale : AUF, 21 Lê Thánh Tông, T.T. Hoàn Kiếm, Hà Nội, Việt Nam
Tél. : +84 4 9331108   Fax : +84 4 8247383   Mobile : +84 91 3248747
⎧ Note personnelle : merci d'éviter de m'envoyer des fichiers PowerPoint   ⎫
⎩ ou Word ; voir http://www.fsf.org/philosophy/no-word-attachments.fr.html

Reply to: