* Match packet address against addresses on interface
@ 2017-02-11 17:13 Michael Weiser
2017-02-12 8:59 ` Pascal Hambourg
0 siblings, 1 reply; 5+ messages in thread
From: Michael Weiser @ 2017-02-11 17:13 UTC (permalink / raw)
To: netfilter
Hi,
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?
I've seen this with pf where you can write "( if0 )" instead of a source
or target address to achieve just that.
As of now I have a small daemon monitoring rtnetlink events, using them
to maintain ipsets for ip{,6}tables which seems rather cumbersome and
fragile.
--
Thanks,
Michael
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Match packet address against addresses on interface
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
0 siblings, 1 reply; 5+ messages in thread
From: Pascal Hambourg @ 2017-02-12 8:59 UTC (permalink / raw)
To: Michael Weiser; +Cc: netfilter
Le 11/02/2017 à 18:13, Michael Weiser a écrit :
>
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Match packet address against addresses on interface
2017-02-12 8:59 ` Pascal Hambourg
@ 2017-02-12 12:43 ` Michael Weiser
2017-02-12 13:15 ` Pascal Hambourg
0 siblings, 1 reply; 5+ messages in thread
From: Michael Weiser @ 2017-02-12 12:43 UTC (permalink / raw)
To: Pascal Hambourg; +Cc: netfilter
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Match packet address against addresses on interface
2017-02-12 12:43 ` Michael Weiser
@ 2017-02-12 13:15 ` Pascal Hambourg
2017-02-12 14:07 ` Michael Weiser
0 siblings, 1 reply; 5+ messages in thread
From: Pascal Hambourg @ 2017-02-12 13:15 UTC (permalink / raw)
To: Michael Weiser; +Cc: netfilter
Le 12/02/2017 à 13:43, Michael Weiser a écrit :
> 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).
I thought you wanted to match only against local addresses attached to a
specific interface, not all interfaces. If that specific interface is
the output interface, then you can add --limit-iface-out.
Otherwise, may I ask why do you need this ?
Only a process with special privileges can send packets with a non local
address.
> 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.
local != private
There is no need for a specific extension to match any given address
prefix such as those defined in RFC1918 : -d/-s already do the job.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Match packet address against addresses on interface
2017-02-12 13:15 ` Pascal Hambourg
@ 2017-02-12 14:07 ` Michael Weiser
0 siblings, 0 replies; 5+ messages in thread
From: Michael Weiser @ 2017-02-12 14:07 UTC (permalink / raw)
To: Pascal Hambourg; +Cc: netfilter
Hi Pascal,
On Sun, Feb 12, 2017 at 02:15:49PM +0100, Pascal Hambourg wrote:
> > iptables -I OUTPUT 1 -p tcp --dport 22 -m addrtype --src-type LOCAL -j ACCEPT
> I thought you wanted to match only against local addresses attached to a
> specific interface, not all interfaces. If that specific interface is the
> output interface, then you can add --limit-iface-out.
Agreed.
> Otherwise, may I ask why do you need this ?
> Only a process with special privileges can send packets with a non local
> address.
My use case is a DMZ bastion/remote access jump (i.e. somewhat exposed)
host where I do not want a process that somehow gained privileges to be
able to e.g. send out spoofed packets right away as well as a kind of
high-level martian filtering by just accepting packets directed at an
address the machine actually has. This collides with IPv6 constantly
changing addresses due to privacy extensions and RAs from my DSL
provider.
I am aware that it mostly is a case of "rampant paranoia"[tm] paired
with "because I can"[tm].
> local != private
> There is no need for a specific extension to match any given address prefix
> such as those defined in RFC1918 : -d/-s already do the job.
I did say dummy, didn't I? :)
--
bye, Michael
Dessau fuer's Volk!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-02-12 14:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-02-12 13:15 ` Pascal Hambourg
2017-02-12 14:07 ` Michael Weiser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox