* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 14:24 ` Harald Welte
@ 2003-07-30 14:51 ` Andreas Jellinghaus
2003-07-30 14:51 ` Andreas Jellinghaus
2003-07-30 14:51 ` Andreas Jellinghaus
2 siblings, 0 replies; 16+ messages in thread
From: Andreas Jellinghaus @ 2003-07-30 14:51 UTC (permalink / raw)
To: Harald Welte; +Cc: netfilter-devel, netfilter, netdev
Hi,
if you are using ipsec from kernel 2.6.* there is no "ipsec0"
interface, and thus using netfilter isn't as easy as it was with
freeswan.
three ways to solve the problem, only tried the first one so far:
1.) configure ipsec in tunnel mode, add your tunnel ip to
the outgoing interface, change the default route to
set the source ip to the tunnel ip.
note: there is no routing step after encapsulating a packet
with ipsec, there was one with freeswan, so this is different.
2.) set a fwmark on an esp packet, it should be there after
unpacking/decryption. didn't try this one.
3.) do not use the build in tunneling. use an explicit ipip tunnel.
that way you have the interface, can use it in netfilter,
can route into it, and the interface will set the right
source address.
[netfilter]
incoming encrypted packets are seen as ESP/AH in INPUT
and then as decrypted packet in INPUT or FORWARD.
outgoing packets are only seen as ESP in OUTPUT.
> > Since ESP packets that reach the mangle INPUT chain are destined for a
> > local process, why not unencapsulate them just before that point?
INPUT only means the ESP will be decrypted/unecapsulated.
after that the decrypted packet will show up in INPUT or FORWARD.
> no. My preferred solution was something like adding a netfilter hook to
> the xfrm4 engine, exactly after decapsulation / decryption of one layer,
> i.e. after xfrm_type.input was called.
>
> iptables could then register the INPUT chain (or probably even a
> seperate POSTXFRM chain) in order to filter on the respective packets.
you can already filter incoming packets. The problem is you
don't know if they came in that way they look now, or if they
came in via ESP packets and got decrypted.
maybe decryption/unencapsulating could leave a mark on the
packet, so we know packets without that mark came in without
ipsec and are bad / attempts to access resources without ipsec?
(maybe fwmark works on that. or an explicit ipip tunnel, so you
have "ipip0" or something as incoming interface).
> Any comments are appreciated.
Regards, Andreas
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 14:24 ` Harald Welte
2003-07-30 14:51 ` Andreas Jellinghaus
@ 2003-07-30 14:51 ` Andreas Jellinghaus
2003-07-30 15:16 ` Harald Welte
` (3 more replies)
2003-07-30 14:51 ` Andreas Jellinghaus
2 siblings, 4 replies; 16+ messages in thread
From: Andreas Jellinghaus @ 2003-07-30 14:51 UTC (permalink / raw)
To: Harald Welte; +Cc: netfilter-devel, netfilter, netdev
Hi,
if you are using ipsec from kernel 2.6.* there is no "ipsec0"
interface, and thus using netfilter isn't as easy as it was with
freeswan.
three ways to solve the problem, only tried the first one so far:
1.) configure ipsec in tunnel mode, add your tunnel ip to
the outgoing interface, change the default route to
set the source ip to the tunnel ip.
note: there is no routing step after encapsulating a packet
with ipsec, there was one with freeswan, so this is different.
2.) set a fwmark on an esp packet, it should be there after
unpacking/decryption. didn't try this one.
3.) do not use the build in tunneling. use an explicit ipip tunnel.
that way you have the interface, can use it in netfilter,
can route into it, and the interface will set the right
source address.
[netfilter]
incoming encrypted packets are seen as ESP/AH in INPUT
and then as decrypted packet in INPUT or FORWARD.
outgoing packets are only seen as ESP in OUTPUT.
> > Since ESP packets that reach the mangle INPUT chain are destined for a
> > local process, why not unencapsulate them just before that point?
INPUT only means the ESP will be decrypted/unecapsulated.
after that the decrypted packet will show up in INPUT or FORWARD.
> no. My preferred solution was something like adding a netfilter hook to
> the xfrm4 engine, exactly after decapsulation / decryption of one layer,
> i.e. after xfrm_type.input was called.
>
> iptables could then register the INPUT chain (or probably even a
> seperate POSTXFRM chain) in order to filter on the respective packets.
you can already filter incoming packets. The problem is you
don't know if they came in that way they look now, or if they
came in via ESP packets and got decrypted.
maybe decryption/unencapsulating could leave a mark on the
packet, so we know packets without that mark came in without
ipsec and are bad / attempts to access resources without ipsec?
(maybe fwmark works on that. or an explicit ipip tunnel, so you
have "ipip0" or something as incoming interface).
> Any comments are appreciated.
Regards, Andreas
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 14:51 ` Andreas Jellinghaus
@ 2003-07-30 15:16 ` Harald Welte
2003-07-30 15:16 ` Harald Welte
` (2 subsequent siblings)
3 siblings, 0 replies; 16+ messages in thread
From: Harald Welte @ 2003-07-30 15:16 UTC (permalink / raw)
To: Andreas Jellinghaus; +Cc: netfilter-devel, netfilter, netdev
[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]
On Wed, Jul 30, 2003 at 04:51:41PM +0200, Andreas Jellinghaus wrote:
> [netfilter]
> incoming encrypted packets are seen as ESP/AH in INPUT
> and then as decrypted packet in INPUT or FORWARD.
ok, great.
> outgoing packets are only seen as ESP in OUTPUT.
this could be a problem. I think there is quite a number of users who
want to impose packet filtering on outgoing locally-originated
packets... and obviously you want to do that at some time _before_ you
hide everything behind crypto..
> you can already filter incoming packets. The problem is you
> don't know if they came in that way they look now, or if they
> came in via ESP packets and got decrypted.
>
> maybe decryption/unencapsulating could leave a mark on the
> packet, so we know packets without that mark came in without
> ipsec and are bad / attempts to access resources without ipsec?
> (maybe fwmark works on that. or an explicit ipip tunnel, so you
> have "ipip0" or something as incoming interface).
This sounds a bit like the existing problem with bridgewalling. They
also have no idea of where the packet originally came from (at least
before the physdev stuff was introduced as solution to this).
--
- Harald Welte <laforge@netfilter.org> http://www.netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 14:51 ` Andreas Jellinghaus
2003-07-30 15:16 ` Harald Welte
@ 2003-07-30 15:16 ` Harald Welte
2003-07-30 15:16 ` Harald Welte
2003-07-30 20:37 ` Dax Kelson
3 siblings, 0 replies; 16+ messages in thread
From: Harald Welte @ 2003-07-30 15:16 UTC (permalink / raw)
To: Andreas Jellinghaus; +Cc: netfilter-devel, netfilter, netdev
[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]
On Wed, Jul 30, 2003 at 04:51:41PM +0200, Andreas Jellinghaus wrote:
> [netfilter]
> incoming encrypted packets are seen as ESP/AH in INPUT
> and then as decrypted packet in INPUT or FORWARD.
ok, great.
> outgoing packets are only seen as ESP in OUTPUT.
this could be a problem. I think there is quite a number of users who
want to impose packet filtering on outgoing locally-originated
packets... and obviously you want to do that at some time _before_ you
hide everything behind crypto..
> you can already filter incoming packets. The problem is you
> don't know if they came in that way they look now, or if they
> came in via ESP packets and got decrypted.
>
> maybe decryption/unencapsulating could leave a mark on the
> packet, so we know packets without that mark came in without
> ipsec and are bad / attempts to access resources without ipsec?
> (maybe fwmark works on that. or an explicit ipip tunnel, so you
> have "ipip0" or something as incoming interface).
This sounds a bit like the existing problem with bridgewalling. They
also have no idea of where the packet originally came from (at least
before the physdev stuff was introduced as solution to this).
--
- Harald Welte <laforge@netfilter.org> http://www.netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 14:51 ` Andreas Jellinghaus
2003-07-30 15:16 ` Harald Welte
2003-07-30 15:16 ` Harald Welte
@ 2003-07-30 15:16 ` Harald Welte
2003-07-30 20:37 ` Dax Kelson
3 siblings, 0 replies; 16+ messages in thread
From: Harald Welte @ 2003-07-30 15:16 UTC (permalink / raw)
To: Andreas Jellinghaus; +Cc: netfilter-devel, netfilter, netdev
[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]
On Wed, Jul 30, 2003 at 04:51:41PM +0200, Andreas Jellinghaus wrote:
> [netfilter]
> incoming encrypted packets are seen as ESP/AH in INPUT
> and then as decrypted packet in INPUT or FORWARD.
ok, great.
> outgoing packets are only seen as ESP in OUTPUT.
this could be a problem. I think there is quite a number of users who
want to impose packet filtering on outgoing locally-originated
packets... and obviously you want to do that at some time _before_ you
hide everything behind crypto..
> you can already filter incoming packets. The problem is you
> don't know if they came in that way they look now, or if they
> came in via ESP packets and got decrypted.
>
> maybe decryption/unencapsulating could leave a mark on the
> packet, so we know packets without that mark came in without
> ipsec and are bad / attempts to access resources without ipsec?
> (maybe fwmark works on that. or an explicit ipip tunnel, so you
> have "ipip0" or something as incoming interface).
This sounds a bit like the existing problem with bridgewalling. They
also have no idea of where the packet originally came from (at least
before the physdev stuff was introduced as solution to this).
--
- Harald Welte <laforge@netfilter.org> http://www.netfilter.org/
============================================================================
"Fragmentation is like classful addressing -- an interesting early
architectural error that shows how much experimentation was going
on while IP was being designed." -- Paul Vixie
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 14:51 ` Andreas Jellinghaus
` (2 preceding siblings ...)
2003-07-30 15:16 ` Harald Welte
@ 2003-07-30 20:37 ` Dax Kelson
2003-07-30 22:51 ` Dax Kelson
3 siblings, 1 reply; 16+ messages in thread
From: Dax Kelson @ 2003-07-30 20:37 UTC (permalink / raw)
To: Andreas Jellinghaus; +Cc: Harald Welte, netfilter-devel, netfilter, netdev
On Wed, 2003-07-30 at 08:51, Andreas Jellinghaus wrote:
> [netfilter]
> incoming encrypted packets are seen as ESP/AH in INPUT
> and then as decrypted packet in INPUT or FORWARD.
Just to clarify, the packets will travel INPUT *twice* (once as ESP and
then in the clear)?
^ permalink raw reply [flat|nested] 16+ messages in thread* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 20:37 ` Dax Kelson
@ 2003-07-30 22:51 ` Dax Kelson
0 siblings, 0 replies; 16+ messages in thread
From: Dax Kelson @ 2003-07-30 22:51 UTC (permalink / raw)
To: Andreas Jellinghaus; +Cc: Harald Welte, netfilter-devel, netfilter, netdev
On Wed, 2003-07-30 at 14:37, Dax Kelson wrote:
> On Wed, 2003-07-30 at 08:51, Andreas Jellinghaus wrote:
> > [netfilter]
> > incoming encrypted packets are seen as ESP/AH in INPUT
> > and then as decrypted packet in INPUT or FORWARD.
>
> Just to clarify, the packets will travel INPUT *twice* (once as ESP and
> then in the clear)?
If this is the case, then I see a problem.
If you have an explicit drop/reject all the bottom (or have a DROP
policy) of INPUT then no IPSEC traffic would be allowed.
I supposed you could add a rule that allowed all ESP traffic before the
the explicit drop.
Dax
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: port-based filtering of ESP packets with in-kernel IPsec?
2003-07-30 14:24 ` Harald Welte
2003-07-30 14:51 ` Andreas Jellinghaus
2003-07-30 14:51 ` Andreas Jellinghaus
@ 2003-07-30 14:51 ` Andreas Jellinghaus
2 siblings, 0 replies; 16+ messages in thread
From: Andreas Jellinghaus @ 2003-07-30 14:51 UTC (permalink / raw)
To: Harald Welte; +Cc: netfilter-devel, netfilter, netdev
Hi,
if you are using ipsec from kernel 2.6.* there is no "ipsec0"
interface, and thus using netfilter isn't as easy as it was with
freeswan.
three ways to solve the problem, only tried the first one so far:
1.) configure ipsec in tunnel mode, add your tunnel ip to
the outgoing interface, change the default route to
set the source ip to the tunnel ip.
note: there is no routing step after encapsulating a packet
with ipsec, there was one with freeswan, so this is different.
2.) set a fwmark on an esp packet, it should be there after
unpacking/decryption. didn't try this one.
3.) do not use the build in tunneling. use an explicit ipip tunnel.
that way you have the interface, can use it in netfilter,
can route into it, and the interface will set the right
source address.
[netfilter]
incoming encrypted packets are seen as ESP/AH in INPUT
and then as decrypted packet in INPUT or FORWARD.
outgoing packets are only seen as ESP in OUTPUT.
> > Since ESP packets that reach the mangle INPUT chain are destined for a
> > local process, why not unencapsulate them just before that point?
INPUT only means the ESP will be decrypted/unecapsulated.
after that the decrypted packet will show up in INPUT or FORWARD.
> no. My preferred solution was something like adding a netfilter hook to
> the xfrm4 engine, exactly after decapsulation / decryption of one layer,
> i.e. after xfrm_type.input was called.
>
> iptables could then register the INPUT chain (or probably even a
> seperate POSTXFRM chain) in order to filter on the respective packets.
you can already filter incoming packets. The problem is you
don't know if they came in that way they look now, or if they
came in via ESP packets and got decrypted.
maybe decryption/unencapsulating could leave a mark on the
packet, so we know packets without that mark came in without
ipsec and are bad / attempts to access resources without ipsec?
(maybe fwmark works on that. or an explicit ipip tunnel, so you
have "ipip0" or something as incoming interface).
> Any comments are appreciated.
Regards, Andreas
^ permalink raw reply [flat|nested] 16+ messages in thread