Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Michael Weiser <michael@weiser.dinsnail.net>
To: Pascal Hambourg <pascal@plouf.fr.eu.org>
Cc: netfilter@vger.kernel.org
Subject: Re: Match packet address against addresses on interface
Date: Sun, 12 Feb 2017 13:43:32 +0100	[thread overview]
Message-ID: <20170212124332.GE2935@weiser.dinsnail.net> (raw)
In-Reply-To: <568f0d90-e6e6-f1ac-4d9b-27b3b21438da@plouf.fr.eu.org>

Hi Pascal,

On Sun, Feb 12, 2017 at 09:59:14AM +0100, Pascal Hambourg wrote:

> > is there an elegant way in either ip{,6}tables or nftables to match
> > addresses in packets against all the addresses set on a specific local
> > interface?
> For the interface the packet is coming in or going out, maybe with the
> iptables 'addrtype' match.

A first test with a rule like

iptables -I OUTPUT 1 -p tcp --dport 22 -m addrtype --src-type LOCAL -j ACCEPT

looks very promising: Allowing out only packets with source addresses
actually assigned to a local interface (tested with hping3 -u -p 22 -a
7.7.7.7 192.168.2.1). If you don't hear from me again, my question is
answered. :)

The thing for dummies like me to note about this is that addrtype
doesn't deal with predefined classes of addresses but the actual state
of things on the interfaces present in the system. Consequently LOCAL
doesn't mean RFC1918 addresses or somesuch but addresses actually
assigned to local interfaces.
-- 
Thanks!
Michael

  reply	other threads:[~2017-02-12 12:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-11 17:13 Match packet address against addresses on interface Michael Weiser
2017-02-12  8:59 ` Pascal Hambourg
2017-02-12 12:43   ` Michael Weiser [this message]
2017-02-12 13:15     ` Pascal Hambourg
2017-02-12 14:07       ` Michael Weiser

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=20170212124332.GE2935@weiser.dinsnail.net \
    --to=michael@weiser.dinsnail.net \
    --cc=netfilter@vger.kernel.org \
    --cc=pascal@plouf.fr.eu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox