Skip to contentSkip to conversation

Ipsec, policy match and PROTO=4

DISCUSSION Thomas Heinz 2 participants 5 messages Jul 25, 2006 – Jul 26, 2006

lore
Share & tools
lore
#0 lore raw

Hallo guys

I have the following standard ipsec tunnel:

[tun_A] host_A [pub_A]-------------[pub_B] host_B [tun_B]

pub_A/B: public IP of host_A/B
tun_A/B: tunnel IP of host_A/B

After establishing the ipsec connection, putting two simple log-all rules in INPUT and OUTPUT like this:

# iptables -I INPUT -j LOG
# iptables -I OUTPUT -j LOG
and pinging tun_B from host_A, I get the following log entries:

IN= OUT=eth0 SRC=tun_A DST=tun_B LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=ICMP TYPE=8 CODE=0 ID=16181 SEQ=1
IN= OUT=eth0 SRC=pub_A DST=pub_B LEN=136 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=ESP SPI=0xxxxxxxxx

Very nice so far: the packet is seen twice, once clear and once encrypted. Now, let's look at the ICMP reply.

IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=pub_B DST=pub_A LEN=136 TOS=0x00 PREC=0x00 TTL=56 ID=57843 PROTO=ESP SPI=0xxxxxxxxx
IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=pub_B DST=pub_A LEN=104 TOS=0x00 PREC=0x00 TTL=56 ID=57843 PROTO=4

Here, we see the packet also twice but the cleartext one has PROTO=4 (ipencap, ipip tunnel).

This has been observed in e.g. this thread:
http://marc.theaimsgroup.com/?l=netfilter-devel&m=114010374229806&w=2

However, I don't see any solution. What is your approach to filter cleartext packets? Adding a rule to allow all PROTO=4 packets does not count ;-)
Is the issue considered a bug?

Thanks for your support.

Best regards,

Thomas

#1 lore raw
Quoted 1 line · Thomas Heinz

Hallo guys

Ciao

Quoted 8 lines

I have the following standard ipsec tunnel:

[tun_A] host_A [pub_A]-------------[pub_B] host_B [tun_B]

pub_A/B: public IP of host_A/B
tun_A/B: tunnel IP of host_A/B

After establishing the ipsec connection, putting two simple log-all

rules

Quoted 6 lines

in INPUT and OUTPUT like this:

# iptables -I INPUT -j LOG
# iptables -I OUTPUT -j LOG
and pinging tun_B from host_A, I get the following log entries:

IN= OUT=eth0 SRC=tun_A DST=tun_B LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=0

DF

Quoted 2 lines

PROTO=ICMP TYPE=8 CODE=0 ID=16181 SEQ=1
IN= OUT=eth0 SRC=pub_A DST=pub_B LEN=136 TOS=0x00 PREC=0x00 TTL=64

ID=0 DF

Quoted 3 lines

PROTO=ESP SPI=0xxxxxxxxx

Very nice so far: the packet is seen twice, once clear and once

encrypted.

Quoted 10 lines

Now, let's look at the ICMP reply.

IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=pub_B DST=pub_A LEN=136 TOS=0x00 PREC=0x00 TTL=56 ID=57843 PROTO=ESP SPI=0xxxxxxxxx
IN=eth0 OUT= MAC=xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx SRC=pub_B DST=pub_A LEN=104 TOS=0x00 PREC=0x00 TTL=56 ID=57843 PROTO=4

Here, we see the packet also twice but the cleartext one has PROTO=4 (ipencap, ipip tunnel).

You aren't seeing the clear text packet because because you should log also the FORWARD chain: 'iptables -I FORWARD -j LOG'

Quoted 5 lines

This has been observed in e.g. this thread:
http://marc.theaimsgroup.com/?l=netfilter-devel&m=114010374229806&w=2

However, I don't see any solution. What is your approach to filter cleartext packets?

You must filter packets in the FORWARD chain, nor INPUT nor OUTPUT

Quoted 1 line

Is the issue considered a bug?

Yes, the issue in the above thread is a know bug to the netfilter team.

#2 lore raw

Hi Marco

Thanks for your reply.

Quoted 4 lines · You

You aren't seeing the clear text packet because because you should log also the FORWARD chain: 'iptables -I FORWARD -j LOG'

Quoted 8 lines
Quoted 5 lines

This has been observed in e.g. this thread:
http://marc.theaimsgroup.com/?l=netfilter-devel&m=114010374229806&w=2

However, I don't see any solution. What is your approach to filter cleartext packets?

You must filter packets in the FORWARD chain, nor INPUT nor OUTPUT

The packets do not traverse the FORWARD chain. I just added log rule, i.e. 'iptables -I FORWARD -j LOG'. Even after issueing 'iptables -I FORWARD -j DROP', the ipsec connection works perfectly (assuming that I accept PROTO=4 packets).

BTW, I used 2.6.16 this time since I currently cannot restart the system. In fact, I would be surprised to see either the ESP or the cleartext packet in FORWARD since both are destined to the local host.

Quoted 4 lines
Quoted 1 line

Is the issue considered a bug?

Yes, the issue in the above thread is a know bug to the netfilter team.

Hm, ok. I wonder how the current state of this issue is and how hard it is to fix this bug.

Best regards,

Thomas

#3 lore raw
Quoted 15 lines · Thomas Heinz

Hi Marco

Thanks for your reply.

Quoted 10 lines · You

You aren't seeing the clear text packet because because you should log also the FORWARD chain: 'iptables -I FORWARD -j LOG'

Quoted 5 lines

This has been observed in e.g. this thread:
http://marc.theaimsgroup.com/?l=netfilter-devel&m=114010374229806&w=2

However, I don't see any solution. What is your approach to filter cleartext packets?

Quoted 7 lines
Quoted 2 lines

You must filter packets in the FORWARD chain, nor INPUT nor OUTPUT

The packets do not traverse the FORWARD chain. I just added log rule, i.e. 'iptables -I FORWARD -j LOG'. Even after issueing 'iptables -I FORWARD -j DROP', the ipsec connection works perfectly (assuming that I accept PROTO=4 packets).

Apologies, I misread your post.

Quoted 3 lines

BTW, I used 2.6.16 this time since I currently cannot restart the system. In fact, I would be surprised to see either the ESP or the cleartext packet in FORWARD since both are destined to the local host.

Yes sure, my fault.

What are you policy for INPUT and OUTPUT chain? ACCEPT or DROP?

#4 lore raw
Quoted 1 line · You

Apologies, I misread your post.

Ok, no problem :)

Quoted 1 line

What are you policy for INPUT and OUTPUT chain? ACCEPT or DROP?

DROP but I don't see how the relation to my problem.

I'm probably going to ask on netfilter-devel about the current state of this bug.

Best regards,

Thomas