Skip to contentSkip to conversation

IPv6 routing

DISCUSSION Jonathan Tripathy 5 participants 16 messages Aug 30, 2010

lore
Share & tools
lore
#0 lore raw

Hi Everyone,

I'm using HE's IP6 Tunnel broker service. I'm trying to use a Ubuntu box as a router. I've set up the tunnel (which connects to HE's server via IPv4).

Everything does work when I don't have any iptables rules. However, I don't wish to leave the box open.

For some reason, forwarding of packets (from HE WAN to the other side of my router) only works when I have my ip6tables INPUT chain to ACCEPT. Even when putting in a state RELATED,ESTABLISHED in there doesn't work.

Does anyone have any ideas why this is the case? I have a funny feeling it has something to do with NDP and ip6tables not marking something as "related".

Thanks

#1 lore raw
Quoted 4 lines · Jonathan Tripathy

Hi Everyone,

I'm using HE's IP6 Tunnel broker service. I'm trying to use a Ubuntu box as a router. I've set up the tunnel (which connects to HE's server via IPv4).

Quoted 8 lines

Everything does work when I don't have any iptables rules. However, I don't wish to leave the box open.

For some reason, forwarding of packets (from HE WAN to the other side of my router) only works when I have my ip6tables INPUT chain to ACCEPT. Even when putting in a state RELATED,ESTABLISHED in there doesn't work.

Does anyone have any ideas why this is the case? I have a funny feeling it has something to do with NDP and ip6tables not marking something as "related".

Thanks

Ok so I added

ip6tables -I INPUT -d ff02::1:ff00:1 -j ACCEPT

to my INPUT chain. The above address being the "solicited node multicast address" of my router, which other hosts on the LAN will send stuff to get it's IP (Bit like ARP for IPv4).

However, when I run a tcpdump, I am now getting this:

06:29:37.241590 IP6 2001:470:1f09:dc5::1 > ff02::1:ff00:2: ICMP6, neighbor solicitation, who has 2001:470:1f09:dc5::2, length 32 06:29:37.241800 IP6 2001:470:1f09:dc5::2 > 2001:470:1f09:dc5::1: ICMP6, neighbor advertisement, tgt is 2001:470:1f09:dc5::2, length 32

It seems like netfilter isn't marking the advertisements as "related" to the solicitation request. I think that this is becuase the request was sent to ff02::1:ff00:2, but the reply came from 2001:470:1f09:dc5::2.

Any ideas what I should do?

Thanks

#2 lore raw
Quoted 9 lines · Jonathan Tripathy

06:29:37.241590 IP6 2001:470:1f09:dc5::1 > ff02::1:ff00:2: ICMP6, neighbor solicitation, who has 2001:470:1f09:dc5::2, length 32 06:29:37.241800 IP6 2001:470:1f09:dc5::2 > 2001:470:1f09:dc5::1: ICMP6, neighbor advertisement, tgt is 2001:470:1f09:dc5::2, length 32

It seems like netfilter isn't marking the advertisements as "related" to the solicitation request. I think that this is becuase the request was sent to ff02::1:ff00:2, but the reply came from 2001:470:1f09:dc5::2.

advertisements need not strictly be a reply to a solicit.

#3 lore raw

you believe you have received

this email in error.

Quoted 7 lines · Jan Engelhardt
Quoted 5 lines · Jonathan Tripathy

06:29:37.241590 IP6 2001:470:1f09:dc5::1> ff02::1:ff00:2: ICMP6, neighbor solicitation, who has 2001:470:1f09:dc5::2, length 32 06:29:37.241800 IP6 2001:470:1f09:dc5::2> 2001:470:1f09:dc5::1: ICMP6, neighbor advertisement, tgt is 2001:470:1f09:dc5::2, length 32

Quoted 6 lines
Quoted 4 lines

It seems like netfilter isn't marking the advertisements as "related" to the solicitation request. I think that this is becuase the request was sent to ff02::1:ff00:2, but the reply came from 2001:470:1f09:dc5::2.

advertisements need not strictly be a reply to a solicit.

So how would I go about adding rules then that allows this?

#4 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 6 lines · Jonathan Tripathy
Quoted 5 lines

06:29:37.241590 IP6 2001:470:1f09:dc5::1> ff02::1:ff00:2: ICMP6, neighbor solicitation, who has 2001:470:1f09:dc5::2, length 32 06:29:37.241800 IP6 2001:470:1f09:dc5::2> 2001:470:1f09:dc5::1: ICMP6, neighbor advertisement, tgt is 2001:470:1f09:dc5::2, length 32

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

It seems like netfilter isn't marking the advertisements as "related" to the solicitation request. I think that this is becuase the request was sent to ff02::1:ff00:2, but the reply came from 2001:470:1f09:dc5::2.

advertisements need not strictly be a reply to a solicit.

So how would I go about adding rules then that allows this?

Ok everyone, I think I found the answer. Just allow -p icmpv6

Does that sound safe enough?

On a side note: netfilter currently has arptables to stop arp cache poisoning. Is there any similar thing for NDP poisoning? I can prevent the actual flow of non-icmpv6 IP traffic to a host by using ip6tables on my bridge device (which sits in the middle of all hosts), however this won't stop DOS attacks..

Cheers

#5 lore raw
Quoted 5 lines · Jonathan Tripathy

On a side note: netfilter currently has arptables to stop arp cache poisoning. Is there any similar thing for NDP poisoning? I can prevent the actual flow of non-icmpv6 IP traffic to a host by using ip6tables on my bridge device (which sits in the middle of all hosts), however this won't stop DOS attacks..

Neighbour discovery is using link local multicast addresses, so you only need to be worried about being flooded from your LAN, same as with arp. If you are worried about it, then I think ip6tables doesn't do much for you at the moment, I am afraid. IPv6 support is a long way from being up to IPv4 standards in Linux (and elsewhere). Please let the list know if you find a solution ;)

BTW, I wouldn't accept all icmpv6 packets if you're security conscious, you really only need the following for basic IPv6 connectivity:

(Taken from Ubuntu's ufw package)

(linked to INPUT chain)

target prot opt source destination
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-advertisement
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-advertisement

(and maybe not even the last two, if you are using static routing).

Quoted 5 lines

Cheers
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 33 lines · Thomas Jacob
Quoted 6 lines · Jonathan Tripathy

On a side note: netfilter currently has arptables to stop arp cache poisoning. Is there any similar thing for NDP poisoning? I can prevent the actual flow of non-icmpv6 IP traffic to a host by using ip6tables on my bridge device (which sits in the middle of all hosts), however this won't stop DOS attacks..

Neighbour discovery is using link local multicast addresses, so you only need to be worried about being flooded from your LAN, same as with arp. If you are worried about it, then I think ip6tables doesn't do much for you at the moment, I am afraid. IPv6 support is a long way from being up to IPv4 standards in Linux (and elsewhere). Please let the list know if you find a solution ;)

BTW, I wouldn't accept all icmpv6 packets if you're security conscious, you really only need the following for basic IPv6 connectivity:

(Taken from Ubuntu's ufw package)

(linked to INPUT chain)

target prot opt source destination
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-advertisement
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-advertisement

Quoted 2 lines

(and maybe not even the last two, if you are using static routing).

Hi Thomas,

Thanks for the excellent explanation.

Yes I am worried about by "LAN" being flooded, as my "LAN" actually hosts public (read: "untrusted") VPS for customers.

But ah well. I'm sure netfilter will have ndptables some day. We're only testing IPv6 at the minute anyway. And we've got iptables which will prevent any non-icmp traffic from working, as well as ebtables to prevent MAC spoofing.

That's good to know about the "fine-tuning" of the rules for icmpv6 - the is exactly what I was looking for!

Cheers

#7 lore raw
Quoted 42 lines · Jonathan Tripathy
Quoted 33 lines · Thomas Jacob
Quoted 6 lines · Jonathan Tripathy

On a side note: netfilter currently has arptables to stop arp cache poisoning. Is there any similar thing for NDP poisoning? I can prevent the actual flow of non-icmpv6 IP traffic to a host by using ip6tables on my bridge device (which sits in the middle of all hosts), however this won't stop DOS attacks..

Neighbour discovery is using link local multicast addresses, so you only need to be worried about being flooded from your LAN, same as with arp. If you are worried about it, then I think ip6tables doesn't do much for you at the moment, I am afraid. IPv6 support is a long way from being up to IPv4 standards in Linux (and elsewhere). Please let the list know if you find a solution ;)

BTW, I wouldn't accept all icmpv6 packets if you're security conscious, you really only need the following for basic IPv6 connectivity:

(Taken from Ubuntu's ufw package)

(linked to INPUT chain)

target prot opt source destination
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-advertisement
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-advertisement

Quoted 2 lines

(and maybe not even the last two, if you are using static routing).

Thanks for the excellent explanation.

Yes I am worried about by "LAN" being flooded, as my "LAN" actually hosts public (read: "untrusted") VPS for customers.

Quoted 7 lines

But ah well. I'm sure netfilter will have ndptables some day. We're only testing IPv6 at the minute anyway. And we've got iptables which will prevent any non-icmp traffic from working, as well as ebtables to prevent MAC spoofing.

That's good to know about the "fine-tuning" of the rules for icmpv6 - the is exactly what I was looking for!

Please check out RFC 4890: Recommendations for Filtering ICMPv6 Messages in Firewalls, which discusses ICMPv6 filtering in details. It even comes with an example shell script for netfilter/ip6tables in the appendix.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#8 lore raw
Quoted 3 lines · Jozsef Kadlecsik

Please check out RFC 4890: Recommendations for Filtering ICMPv6 Messages in Firewalls, which discusses ICMPv6 filtering in details. It even comes with an example shell script for netfilter/ip6tables in the appendix.

Are you sure that this is still accurate for current kernels?

For instance, I would have assumed that things like destination-unreachable or packet-too-big are handled by the stateful inspection code (i.e. are matched by --state RELATED, ESTABLISHED) same as for IPv4?

#9 lore raw
Quoted 6 lines · Thomas Jacob
Quoted 3 lines · Jozsef Kadlecsik

Please check out RFC 4890: Recommendations for Filtering ICMPv6 Messages in Firewalls, which discusses ICMPv6 filtering in details. It even comes with an example shell script for netfilter/ip6tables in the appendix.

Quoted 6 lines

Are you sure that this is still accurate for current kernels?

For instance, I would have assumed that things like destination-unreachable or packet-too-big are handled by the stateful inspection code (i.e. are matched by --state RELATED, ESTABLISHED) same as for IPv4?

The sample script in the RFC tries to handle both cases: kernel with and without IPv6 connection tracking (STATE_ENABLED shell variable).

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#10 lore raw
Quoted 2 lines · Jozsef Kadlecsik

The sample script in the RFC tries to handle both cases: kernel with and without IPv6 connection tracking (STATE_ENABLED shell variable).

I noticed that, but even the stateful part explicitly references the actual icmpv6 type.

AFAIK, in IPv4 netfilter you would not need to do that as the ancillary ICMP traffic caused by existing conntrack entries is matched by ESTABLISHED, RELATED automatically.

Is this not the case for IPv6?

The code snippet in question:

if [ "$STATE_ENABLED" -eq "1" ]
then
# Allow incoming destination unreachable messages # only for existing sessions
for inner_prefix in $INNER_PREFIXES
do
ip6tables -A icmpv6-filter -m state -p icmpv6 \
-d $inner_prefix \
--state ESTABLISHED,RELATED --icmpv6-type \
destination-unreachable -j ACCEPT
done
else
# Allow incoming destination unreachable messages for inner_prefix in $INNER_PREFIXES
do
ip6tables -A icmpv6-filter -p icmpv6 -d $inner_prefix \
--icmpv6-type destination-unreachable -j ACCEPT
done
fi

#11 lore raw
In reply to Jonathan Tripathy
Quoted 2 lines · Jonathan Tripathy

But ah well. I'm sure netfilter will have ndptables some day. We're only testing IPv6 at the minute anyway.

Well, it will probably be an ip6tables module, since in IPv6 the link layer resolution protocol is actually built on top of IPv6 icmp, rather than being an independent layer 3 protocol as ARP is.

Quoted 3 lines

And we've got iptables which will
prevent any non-icmp traffic from working, as well as ebtables to prevent MAC spoofing.

Out of curiosity, what exactly are you trying to filter with your bridge? Is the bridge running on the VPS host, and each virtual machine has it's own virtual network interface?

#12 lore raw
Quoted 10 lines · Thomas Jacob
Quoted 3 lines · Jonathan Tripathy

But ah well. I'm sure netfilter will have ndptables some day. We're only testing IPv6 at the minute anyway.

Well, it will probably be an ip6tables module, since in IPv6 the link layer resolution protocol is actually built on top of IPv6 icmp, rather than being an independent layer 3 protocol as ARP is.

Ah yes, that sounds more likely

Quoted 9 lines
Quoted 4 lines

And we've got iptables which will
prevent any non-icmp traffic from working, as well as ebtables to prevent MAC spoofing.

Out of curiosity, what exactly are you trying to filter with your bridge? Is the bridge running on the VPS host, and each virtual machine has it's own virtual network interface?

That's correct. I'm making use of physdev a lot

#13 lore raw
In reply to Thomas Jacob

Hello,

Quoted 13 lines · Thomas Jacob

(linked to INPUT chain)

target prot opt source destination
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp neighbour-advertisement
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-solicitation
ACCEPT ipv6-icmp anywhere anywhere
ipv6-icmp router-advertisement

Quoted 2 lines

(and maybe not even the last two, if you are using static routing).

A router accepts router solicitation and ignores router advertisement. A host accepts router advertisement and ignores router solicitation.

#14 lore raw
In reply to Jonathan Tripathy
Quoted 2 lines · Jonathan Tripathy

you believe you have received
this email in error.

My beliefs are not up to discussion here :-)

Quoted 21 lines · Jan Engelhardt
Quoted 7 lines · Jonathan Tripathy
Quoted 6 lines

06:29:37.241590 IP6 2001:470:1f09:dc5::1> ff02::1:ff00:2: ICMP6, neighbor solicitation, who has 2001:470:1f09:dc5::2, length 32 06:29:37.241800 IP6 2001:470:1f09:dc5::2> 2001:470:1f09:dc5::1: ICMP6, neighbor advertisement, tgt is 2001:470:1f09:dc5::2, length 32

Quoted 6 lines
Quoted 4 lines

It seems like netfilter isn't marking the advertisements as "related" to the solicitation request. I think that this is becuase the request was sent to ff02::1:ff00:2, but the reply came from 2001:470:1f09:dc5::2.

advertisements need not strictly be a reply to a solicit.

So how would I go about adding rules then that allows this? --
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw
Quoted 7 lines · Jan Engelhardt
Quoted 3 lines · Jonathan Tripathy

you believe you have received
this email in error.

My beliefs are not up to discussion here :-)

Sorry about that, that was what was left of the default email footer