All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pascal Hambourg <pascal@plouf.fr.eu.org>
To: Netfilter Users Mailing list <netfilter@vger.kernel.org>
Subject: Re: iptables: unknown protocol "!" specified
Date: Sun, 22 Nov 2015 18:20:26 +0100	[thread overview]
Message-ID: <5651F95A.2060604@plouf.fr.eu.org> (raw)
In-Reply-To: <alpine.LNX.2.00.1511220946050.3864@maria.rogerprice.org>

Roger Price a écrit :
> On Sun, 22 Nov 2015, Pascal Hambourg wrote:
> 
>> No, it means to match anything but TCP. There are many other protocols
>> than TCP, UDP and ICMP.
> 
> Aha! Does this mean that chapter 10.1 of the iptables tutorial at 
> https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html#GENERICMATCHES 
> is both syntactically and semantically wrong?

I'm afraid yes. I had read this tutorial but hadn't spotted this big
mistake. I wonder where it comes from. I have searched in early releases
of iptables, but "all" or 0 has consistently meant "all", not just TCP,
UDP and ICMP.

> Quoting: << ALL means that it matches only TCP, UDP and ICMP. If this 
> match is given the integer value of zero (0), it means ALL protocols, 
> which in turn is the default behavior, if the --protocol match is not 
> used. This match can also be inversed with the ! sign, so --protocol ! tcp 
> would mean to match UDP and ICMP. >>
> 
> Should this say:
> 
> << ALL matches every protocol given in /etc/protocols, i.e. all protocols 
> in the interval (0..255).  ALL is the default behaviour and can also be 
> specified by writing 0 (zero). The match may be reversed by writing "! 
> --protocol x" which means all the 256 protocol numbers except x.  E.g. "! 
> -p tcp" means the protocols in intervals (0..5) and (7..255).  >>

Yes, or just quote the relevant part of the manpage :

[!] -p, --protocol protocol
      The protocol of the rule or of the packet to check.  The  speci-
      fied protocol can be one of tcp, udp, udplite, icmp, icmpv6,esp,
      ah, sctp, mh or the special  keyword  "all",  or  it  can  be  a
      numeric  value, representing one of these protocols or a differ-
      ent one.  A protocol name from /etc/protocols is  also  allowed.
      A "!" argument before the protocol inverts the test.  The number
      zero is equivalent to all. "all" will match with  all  protocols
      and is taken as default when this option is omitted.  Note that,
      in ip6tables, IPv6 extension headers except esp are not allowed.
      esp  and  ipv6-nonext  can be used with Kernel version 2.6.11 or
      later.  The number zero is equivalent to all, which  means  that
      you  cannot test the protocol field for the value 0 directly. To
      match on a HBH header, even if it were the last, you cannot  use
      -p 0, but always need -m hbh.

> If people have believed the tutorial and used "! -p icmp" as a shorthand 
> for "TCP and UDP", then they will be letting through more than they 
> expect.

Bottom line : do not trust tutorials too much. Read the manpage.

      reply	other threads:[~2015-11-22 17:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-21 20:48 iptables: unknown protocol "!" specified Roger Price
2015-11-21 20:57 ` Neal P. Murphy
2015-11-21 21:10   ` Roger Price
2015-11-22  8:18 ` Pascal Hambourg
2015-11-22 16:05   ` Roger Price
2015-11-22 17:20     ` Pascal Hambourg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5651F95A.2060604@plouf.fr.eu.org \
    --to=pascal@plouf.fr.eu.org \
    --cc=netfilter@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.