ubuntu:networking:configuration:configure_ipv6
Differences
This shows you the differences between two versions of the page.
ubuntu:networking:configuration:configure_ipv6 [2021/01/07 11:26] – created peter | ubuntu:networking:configuration:configure_ipv6 [2021/01/08 15:27] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Ubuntu - Networking - Configuration - Configure IPv6 ====== | ||
- | |||
- | <WRAP info> | ||
- | **NOTE**: | ||
- | |||
- | You will need to use your own prefix(es) when running the command. | ||
- | |||
- | Similarly, I use 10.111.222.33 as example IPv4 address of the PoP endpoint, which you will need to alter. | ||
- | </ | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | ===== Configuring the packet filter ===== | ||
- | |||
- | Most IPv6-related filtering must be configured via ip6tables (read on further down about IPv6 in IPv4 tunneling, for exceptions to this). | ||
- | |||
- | The following is a simple default ruleset to start with, which I put into / | ||
- | |||
- | <file bash / | ||
- | *filter | ||
- | :INPUT DROP [0:0] | ||
- | :FORWARD DROP [0:0] | ||
- | :OUTPUT DROP [0:0] | ||
- | :in-new - [0:0] | ||
- | |||
- | ### INPUT chain | ||
- | |||
- | # allow all loopback traffic | ||
- | -A INPUT -i lo -j ACCEPT | ||
- | |||
- | # RT0 processing is disabled since 2.6.20.9 | ||
- | #-A INPUT -m rt --rt-type 0 -j REJECT | ||
- | |||
- | # allow all ICMP traffic | ||
- | -A INPUT -p icmpv6 -j ACCEPT | ||
- | |||
- | # packets belonging to an establish connection or related to one can pass | ||
- | -A INPUT -m state --state RELATED, | ||
- | # packets that are out-of-sequence are silently dropped | ||
- | -A INPUT -m state --state INVALID -j DROP | ||
- | # new connections unknown to the kernel are handled in a separate chain | ||
- | -A INPUT -m state --state NEW -j in-new | ||
- | |||
- | # pass SYN packets for SSH | ||
- | -A in-new -p tcp -m tcp --dport 22 --syn -j ACCEPT | ||
- | |||
- | # log and reject everything else | ||
- | -A INPUT -m limit --limit 3/min --limit-burst 10 -j LOG --log-prefix " | ||
- | -A INPUT -j REJECT | ||
- | |||
- | ### OUTPUT chain | ||
- | |||
- | # RT0 processing is disabled since 2.6.20.9 | ||
- | #-A OUTPUT -m rt --rt-type 0 -j REJECT | ||
- | |||
- | # allow outgoing traffic, explicitly (despite chain policy) | ||
- | -A OUTPUT -j ACCEPT | ||
- | |||
- | ### FORWARD chain | ||
- | |||
- | # RT0 processing is disabled since 2.6.20.9 | ||
- | #-A FORWARD -m rt --rt-type 0 -j REJECT | ||
- | |||
- | # disallow forwarded traffic, explicitly (despite chain policy) | ||
- | -A FORWARD -j REJECT | ||
- | |||
- | COMMIT | ||
- | </ | ||
- | |||
- | The ruleset should be fairly obvious, but you might wonder about my use of REJECT and allowing all [[http:// | ||
- | |||
- | Well, to hell with all that! I don't see a single reason or attack vector that is foiled by DROP or disallowing ICMP. In fact, it's just security by obscurity, and mighty inconvenient at the same time. ICMP is also much more important with IPv6 than with IPv4 (it replaces [[http:// | ||
- | |||
- | Then there is [[http:// | ||
- | |||
- | ---- | ||
- | |||
- | ===== Setting system parameters ===== | ||
- | |||
- | The / | ||
- | |||
- | <code bash> | ||
- | net.ipv6.conf.default.autoconf = 0 | ||
- | net.ipv6.conf.default.accept_ra = 0 | ||
- | net.ipv6.conf.default.accept_ra_defrtr = 0 | ||
- | net.ipv6.conf.default.accept_ra_rtr_pref = 0 | ||
- | net.ipv6.conf.default.accept_ra_pinfo = 0 | ||
- | net.ipv6.conf.default.accept_source_route = 0 | ||
- | net.ipv6.conf.default.accept_redirects = 0 | ||
- | net.ipv6.conf.default.forwarding = 0 | ||
- | net.ipv6.conf.all.autoconf = 0 | ||
- | net.ipv6.conf.all.accept_ra = 0 | ||
- | net.ipv6.conf.all.accept_ra_defrtr = 0 | ||
- | net.ipv6.conf.all.accept_ra_rtr_pref = 0 | ||
- | net.ipv6.conf.all.accept_ra_pinfo = 0 | ||
- | net.ipv6.conf.all.accept_source_route = 0 | ||
- | net.ipv6.conf.all.accept_redirects = 0 | ||
- | net.ipv6.conf.all.forwarding = 0 | ||
- | </ | ||
- | |||
- | Obviously, for gateways, you want to enable forwarding, and on machines where you want to use autoconfiguration, | ||
- | |||
- | If you're curious, the default values (the first seven lines) set the defaults for new interfaces, while the all values override the values for all interfaces. I am not sure whether this is a permanent overwrite, or just overwrites all existing interfaces, which is why I simply set the parameters for both. | ||
- | |||
- | Unfortunately, | ||
- | |||
- | At this moment, I suggest that you add pre-up headers to the iface stanzas of all interfaces to be sure: | ||
- | |||
- | <code bash> | ||
- | pre-up echo 0 > / | ||
- | pre-up echo 0 > / | ||
- | pre-up echo 0 > / | ||
- | pre-up echo 0 > / | ||
- | pre-up echo 0 > / | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Getting connected ===== | ||
- | |||
- | If you already have an IPv6 address, you're basically ready to go, but may want to read further down on how to connect your local network to the IPv6 Internet as well. If you are searching for a provider, have a look at the [[http:// | ||
- | |||
- | If you are reading up to here, I assume you are connected to the 'Net with IPv4. There are two ways for you to move towards IPv6: 6to4 or by way of a tunnel provider. | ||
- | |||
- | With the tunnel approach, IPv6 packets are wrapped up in IPv4 packets on your host, and sent to the IPv4 address of your tunnel provider, who has native IPv6 connectivity. The tunnel provider unwraps your packet and shoves the contained IPv6 packet onto the backbone. The IPv6 address you used as source address is routed to the tunnel provider, so any replies arrive at their machines, where they' | ||
- | |||
- | There are a few tunnel providers out there. | ||
- | |||
- | ---- | ||
- | |||
- | ===== Tunnel types ===== | ||
- | |||
- | Your first step with SixXS will be to request a tunnel. SixXS offers three types of tunnels: | ||
- | |||
- | * static tunnels, for those with static IPs, | ||
- | * heartbeat tunnels, for those with dynamic IPs, and | ||
- | * [[https:// | ||
- | |||
- | Each of these tunnels have advantages and disadvantages, | ||
- | |||
- | I suggest to use the first type of tunnel that fits your situation. Debian' | ||
- | |||
- | During registration, | ||
- | |||
- | Other tunnel brokers include [[http:// | ||
- | |||
- | ---- | ||
- | |||
- | ===== Setting up the tunnel ===== | ||
- | |||
- | Once your tunnel request gets approved, you'll get a /64 prefix, in which you only use two addresses: the PoP will configure the :1 address and you need to configure your host to use the :2 address on the tunnel interface. You'll also be told the IPv4 address of your PoP " | ||
- | |||
- | Joey Hess taught me that aiccu can set up the interface for you, using the data it queries from the SixXS registration (TIC) server. I tried it, and it works. However, I prefer the pure [[http:// | ||
- | |||
- | <code bash> | ||
- | auto sixxs | ||
- | iface sixxs inet6 v4tunnel | ||
- | endpoint 10.111.222.33 | ||
- | address 2001: | ||
- | netmask 64 | ||
- | gateway 2001: | ||
- | ttl 64 | ||
- | pre-up ip6tables-restore < / | ||
- | up ip link set mtu 1480 dev $IFACE | ||
- | up invoke-rc.d aiccu start | ||
- | down invoke-rc.d aiccu stop | ||
- | </ | ||
- | |||
- | Make sure to read about [[http:// | ||
- | |||
- | The last two lines are only needed for heartbeat tunnels and assume that you have configured aiccu appropriately. | ||
- | |||
- | Also, when using / | ||
- | |||
- | For AYIYA tunnels, the following can be used, if you prefer to be able to bring up the interface with the usual ifup command, rather than having it appear when the daemon starts. | ||
- | |||
- | <code bash> | ||
- | auto sixxs | ||
- | iface sixxs inet manual | ||
- | pre-up invoke-rc.d aiccu start | ||
- | up sleep 1 | ||
- | up ip link set mtu 1280 dev $IFACE | ||
- | post-down invoke-rc.d aiccu stop | ||
- | </ | ||
- | |||
- | It is also a good idea to prevent aiccu from starting at boot when using this method: | ||
- | |||
- | <code bash> | ||
- | update-rc.d aiccu disable | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Allowing proto-41 traffic ===== | ||
- | |||
- | Unfortunately, | ||
- | |||
- | <code bash> | ||
- | iptables -I INPUT -p ipv6 -s 10.111.222.33/ | ||
- | </ | ||
- | |||
- | For AYIYA, you need to open port 5072, either for UDP, TCP, or SCTP, depending on how you configured it. Also have a look at this [[http:// | ||
- | |||
- | In most situations, the FORWARD chain does not get such a rule, since the tunnel terminates at the gateway, which routes to a native IPv6 network, or another tunnel. Allowing tunnels through a gateway is almost always a bad thing, as it would allow undetected and untraceable traffic from compromised boxes in the local network. The OUTPUT chain also does not need such a rule, if you have configured stateful filtering properly. | ||
- | |||
- | Now bring up the interface and verify the connection: | ||
- | |||
- | <code bash> | ||
- | # ifup sixxs | ||
- | # ping6 -nc1 2001: | ||
- | PING 2001: | ||
- | 64 bytes from 2001: | ||
- | [...] | ||
- | # ping6 -nc1 ipv6.aerasec.de | ||
- | PING ipv6.aerasec.de(2001: | ||
- | 64 bytes from 2001: | ||
- | [...] | ||
- | </ | ||
- | |||
- | Welcome to the Internet of the future! | ||
- | |||
- | ---- | ||
- | |||
- | ===== Setting up an IPv6-capable gateway ===== | ||
- | |||
- | Your IPv6 connection works, but it's limited to a single address, and you do not get to specify the reverse DNS PTR record for it. Since the concept of NAT is mostly absent from IPv6 (thanks! thanks! thanks!), you will not be able to connect any other hosts to the IPv6 network. If your local network has a few hosts behind a gateway, you will need to request a subnet from SixXS and configure your gateway (which has the tunnel connection) appropriately. Don't worry, this is not really very difficult. | ||
- | |||
- | First, request a subnet for your tunnel from your PoP via your SixXS homepage. Once approved, you will get a /48 prefix for your own use: 2^80 — 1.2 heptillion addresses which are yours to assign to every dust particle in your office or home, if you so desire. | ||
- | |||
- | The way I set it up is to add the first of these addresses to your internal interface on the gateway, by adding the following two lines to the interface' | ||
- | |||
- | <code bash> | ||
- | up ip -6 addr add 2001: | ||
- | down ip -6 addr del 2001: | ||
- | </ | ||
- | |||
- | Instead of bringing the interface down and up, just run ip -6 addr add <your prefix> dev eth0. Note the use of the /64 prefix instead of the /48 that got assigned, leaving only 20 pentillion addresses. Oh no! The reason for this is buried in the specs: basically, /48 is a site prefix, but individual networks should not be larger than /64, which is the prefix length of links in the IPv6 domain. | ||
- | |||
- | The /64 prefix is only one of 65536 different /64 prefixes you can use from your /48 prefix. Since it's unlikely that you'll use them all, it's a good idea to route unused ones to an unreachable destination, | ||
- | |||
- | <code bash> | ||
- | up ip -6 route add 2001: | ||
- | down ip -6 route del 2001: | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Enabling forwarding ===== | ||
- | |||
- | Now is also a good time to enable IPv6 forwarding, e.g. like so: | ||
- | |||
- | <code bash> | ||
- | # echo net.ipv6.conf.all.forwarding = 1 >> / | ||
- | # sysctl -p | ||
- | </ | ||
- | |||
- | Obviously, you will also need to change the policy on the ip6tables FORWARD chain. For now, let's just set it to accept all traffic between the local network behind eth0 and the Internet behind eth1. You should later create a proper ruleset, though! (remember to use your own prefix) | ||
- | |||
- | <code bash> | ||
- | # ip6tables -I FORWARD -i eth0 -o eth1 -s 2001: | ||
- | # ip6tables -I FORWARD -i eth1 -o eth0 -d 2001: | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Advertising addresses on your local network ===== | ||
- | |||
- | The final step is to spread the love to your local network. Refrain from selecting addresses from your subnet and assigning them to the local hosts, or wondering how to configure the [[http:// | ||
- | |||
- | On the gateway, you need to install [[http:// | ||
- | |||
- | <code bash> | ||
- | interface eth0 | ||
- | { | ||
- | AdvSendAdvert on; | ||
- | prefix 2001: | ||
- | { | ||
- | }; | ||
- | }; | ||
- | </ | ||
- | |||
- | Note again how we advertise a /64 network rather than the /48 we " | ||
- | |||
- | Restart radvd and run over to another host to witness how it automagically gets connected to the IPv6 network by scanning / | ||
- | |||
- | If you don't like the automagic aspect of this, look into stateful configuration, | ||
- | |||
- | ---- | ||
- | |||
- | ===== Choosing source addresses ===== | ||
- | |||
- | Even though you have obtained a /48 network and configured the gateway appropriately, | ||
- | |||
- | Unfortunately, | ||
- | |||
- | The best solution is to add 2001: | ||
- | |||
- | <code bash> | ||
- | iface sixxs inet6 v4tunnel | ||
- | […] | ||
- | up ip -6 addr add 2001: | ||
- | down ip -6 addr del 2001: | ||
- | </ | ||
- | |||
- | Here is [[https:// | ||
- | |||
- | ---- | ||
- | |||
- | ===== Resolving names ===== | ||
- | |||
- | Take note of the IPv6 address of each host. There' | ||
- | |||
- | If you're serious about IPv6, you can tell SixXS to delegate reverse lookups for the IPv6 addresses to your DNS servers, but you ought to refrain from [[http:// | ||
- | |||
- | <code bash> | ||
- | dig +trace -x 2001: | ||
- | </ | ||
- | |||
- | Note that [[http:// | ||
- | |||
- | <code bash> | ||
- | % host pulse.madduck.net | ||
- | pulse.madduck.net has address 130.60.75.48 | ||
- | pulse.madduck.net has IPv6 address 2001: | ||
- | pulse.madduck.net mail is handled by 99 b.mx.madduck.net. | ||
- | pulse.madduck.net mail is handled by 10 a.mx.madduck.net. | ||
- | |||
- | % host 2001: | ||
- | 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.1.f.f.0.e.1.4.1.0.0.2.ip6.arpa | ||
- | domain name pointer pulse.madduck.net. | ||
- | </ | ||
- | |||
- | Oh, and if you're really that curious about how IPv6 addresses are computed from MAC addresses, read [[http:// | ||
- | |||
- | - inserting ff:fe into the middle of the MAC address to yield aa: | ||
- | - removing the odd colons to yield aabb: | ||
- | - flipping the second lowest bit of the first octet to yield a8bb: | ||
- | - concatenating the prefix and this result to get 2001: | ||
- | |||
- | Other (easier) ways to determine the local component of an IPv6 address are: | ||
- | |||
- | * look at the output of ip -6 addr and find the address starting with fe80:: on the interface you want to connect to the IPv6 network; following the two colons is the interface' | ||
- | * use [[http:// | ||
- | |||
- | |||
- | If you find your (Windows) IPv6 addresses changing all the time, you might be faced by " | ||
- | |||
- | ---- | ||
- | |||
- | ===== Remaining issues ===== | ||
- | |||
- | Even though my IPv6 connectivity works, I have two remaining issues. | ||
- | |||
- | ---- | ||
- | |||
- | ===== Mapping names to laptops ===== | ||
- | |||
- | Laptops generally have two interfaces, one with a cable, and the other wireless. Both of these interfaces will have separate MAC addresses, and by extension, the laptop will have different IPv6 addresses depending on how it is connected to the local network. | ||
- | |||
- | I want to be able to connect to laptops without knowing the medium they use to connect to the network. Unfortunately, | ||
- | |||
- | * override the MAC address of one interface with that of the other, which is going to cause bgi problems in the case when the laptop (accidentally) gets connected to the same network twice; | ||
- | * add both IPv6 addresses as AAAA records to the laptop' | ||
- | * set up [[http:// | ||
- | The second solution works for me for now, but I am interested in the third. | ||
- | |||
- | In response to this document, Andreas Henriksson has suggested the replace the stateless configuration (radvd) with stateful configuration, | ||
- | |||
- | Jeroen Massar suggests to unite cable and wireless into a bridged interface, which seems like a very good idea. | ||
- | |||
- | ---- | ||
- | |||
- | ===== Kernel versions and stateful connection tracking ===== | ||
- | |||
- | Even though the default kernel of Debian etch, our current stable release, speaks IPv6, I cannot recommend it for deployment, as the 2.6.18 kernel [[http:// | ||
- | |||
- | A remedy exists, however: Debian " | ||
- | |||
- | ---- | ||
- | |||
- | ===== Xen and IPv6 ===== | ||
- | |||
- | One drawback of switching to 2.6.24 is that you cannot run a dom0 on that machine any longer, so by practical extension, you cannot connect it to the IPv6 network with a packet filter in place. Supposedly, running 2.6.24 instances on a 2.6.18 dom0 is reported to work, however. | ||
- | |||
- | Debian " | ||
- | |||
- | ---- | ||
- | |||
- | ===== References ===== | ||
- | |||
- | http:// | ||
- | |||
- | http:// | ||
- | |||
- | # | ||
ubuntu/networking/configuration/configure_ipv6.1610018794.txt.gz · Last modified: 2021/01/07 11:26 by peter