Difference between pages "Linux Containers" and "IPv6 Networking"

From Funtoo
(Difference between pages)
Jump to: navigation, search
(/lxc/funtoo0/config to /etc/lxc/funtoo0.conf)
 
(Using Unique Local IPv6 Unicast Addresses)
 
Line 1: Line 1:
Linux Containers, or LXC, is a Linux feature that allows Linux to run one or more isolated virtual systems (with their own network interfaces, process namespace, user namespace, and power state) using a single Linux kernel on a single server.
+
= Introduction =
  
== Status ==
+
[[wikipedia:IPv6|IPv6]] is an redesigned and improved version of the IPv4 protocol, and is intended to start replacing IPv4 in 2011 and beyond as the [[wikipedia:IPv4_address_exhaustion|IPv4 global address space becomes exhausted]]. IPv6 includes a number of improvements over IPv4, including most notably 128-bit addressing, simplified protocol header, integrated IPSec and Multicast implementations, improved discovery, flexibility and router interaction, and improved facilities for auto-configuration. IPv6 also marks the end of [[wikipedia:Network_address_translation|Network Address Translation]] (NAT), which is not recommended or necessary with IPv6. While it's possible to use non-routable addresses with IPv6, this is not a requirement and it is possible for any IPv6 device to have its own globally routable IP address if desired.
  
As of Linux kernel 3.1.5, LXC is usable for isolating your own private workloads from one another. It is not yet ready to isolate potentially malicious users from one another or the host system. For a more mature containers solution that is appropriate for hosting environments, see [[OpenVZ]].
+
== Addressing ==
  
LXC containers don't yet have their own system uptime, and they see everything that's in the host's <tt>dmesg</tt> output, among other things. But in general, the technology works.
+
IPv6 addresses consist of 128 bits. The first 64 bits are used for the network and subnet portion of the address, while the remaining 64 bits are used for the host portion of the address. For more information on how to represent IPv6 addresses, please see the Presentation section of the [[wikipedia:IPv6_address|IPv6 address]] page on Wikipedia.  
  
== Basic Info ==
+
=== Network Masks ===
  
 +
IPv6 addresses also have an associated network mask, which is typically written as a trailing "/64" or "/48" at the end of the address, which specifies what bits of the address are used for network and subnet parts. For example, a "/48" mask specifies that addresses use a 48-bit network part, followed by a 16-bit subnet part (allowing for 2^16 subnets), followed by a 64-bit host part (allowing for up to 2<sup>64</sup> hosts for each of the 2<sup>16</sup> subnets to be specified.) In contrast, a "/64" mask specifies that addresses use a 64-bit network part, no subnet part, and a 64-bit host part (allowing up to 2<sup>64</sup> hosts total to be specified.) This means that if you are issued a "/64" set of addresses, you will not be able to define any subnets, but if you are issued a "/48" set of addresses, you will be able to define up to 2<sup>16</sup> subnets.
  
* Linux Containers are based on:
+
=== Address Space and Security ===
** Kernel namespaces for resource isolation
+
** CGroups for resource limitation and accounting
+
  
app-emulation/lxc are userspace tools for Linux containers
+
IPv6 also uses a global, flat address space. IPv6 is designed so that any device that needs to communicate on the Internet is able to have a unique globally-routable address. With IPv6, there is no need for using [[wikipedia:Network_address_translation|Network Address Translation]] (NAT). With IPv4, NAT is often used as a means of protecting systems from being accessed by malicious users. With IPv6, firewalls are typically used instead of NAT for restricting access to systems. With IPv6, it is normal for all machines on your home network to have "globally routable" addresses, the equivalent of a "public IP" in the world of IPv4. It is important to understand that this is the way that IPv6 is intended to be used for the majority of users, and that an IPv6-enabled router will no longer be performing NAT for you.
  
== Control groups ==
+
=== Using IPv6 ===
  
* Control groups (cgroups) in kernel since 2.6.24
+
There are several ways to use IPv6 with Funtoo Linux. Here are some possibilities:
** Allows aggregation of tasks and their children
+
** Subsystems (cpuset, memory, blkio,...)
+
** accounting - to measure how much resources certain systems use
+
** resource limiting - groups can be set to not exceed a set memory limit
+
** prioritization - some groups may get a larger share of CPU
+
** control - freezing/unfreezing of cgroups, checkpointing and restarting
+
** No disk quota limitation ( -> image file, LVM, XFS, directory tree quota,...)
+
  
== Subsystems ==
+
* Participating in an existing IPv6 network
<br>
+
* Creating a local IPv6 over IPv4 tunnel
<console>
+
* Enabling IPv6 on your router, possibly via a tunnel (several ISP uses '''6rd'''...)
###i## cat /proc/cgroups
+
* Unique Local IPv6 Unicast Addresses (site local)
subsys_name hierarchy num_cgroups enabled
+
cpuset
+
cpu
+
cpuacct
+
memory
+
devices
+
freezer
+
blkio
+
perf_event
+
hugetlb
+
</console>
+
  
#cpuset    -> limits tasks to specific CPU/CPUs
+
==== Participating in IPv6 Network ====
#cpu        -> CPU shares
+
#cpuacct    -> CPU accounting
+
#memory    -> memory and swap limitation and accounting
+
#devices    -> device allow deny list
+
#freezer    -> suspend/resume tasks
+
#blkio      -> I/O priorization (weight, throttle, ...)
+
#perf_event -> support for per-cpu per-cgroup monitoring [http://lwn.net/Articles/421574/ perf_events]
+
#hugetlb    -> cgroup resource controller for HugeTLB pages  [http://lwn.net/Articles/499255/ hugetlb]
+
  
== Configuring the Funtoo Host System ==
+
The first approach is an option if your Funtoo Linux system happens to be on an IPv6 network, or you desire to set up an IPv6 network. In this case, the Funtoo Linux system simply needs to be configured to participate in this IPv6 network -- and can also participate in an IPv4 network simultaneously. If you will be configuring an IPv6-compatible router, then you will simply configure your Funtoo Linux system to participate in this network.
  
=== Install LXC kernel ===
+
==== Local IPv6 over IPv4 Tunnel ====
Any kernel beyond 3.1.5 will probably work. Personally I prefer {{Package|sys-kernel/gentoo-sources}} as these have support for all the namespaces without sacrificing the xfs, FUSE or NFS support for example. These checks were introduced later starting from kernel 3.5, this could also mean that the user namespace is not working optimally.
+
  
* User namespace (EXPERIMENTAL) depends on EXPERIMENTAL and on UIDGID_CONVERTED
+
Another approach for using IPv6 is to configure an IPv6 over IPv4 tunnel locally on your Funtoo Linux system, in cooperation with a tunnel provider. This will allow you to use an existing IPv4 network to connect a single Funtoo Linux system to IPv6. It is also possible to configure this system to serve as an IPv6 router.
** config UIDGID_CONVERTED
+
*** True if all of the selected software components are known to have uid_t and gid_t converted to kuid_t and kgid_t where appropriate and are otherwise safe to use with the user namespace.
+
**** Networking - depends on NET_9P = n
+
**** Filesystems - 9P_FS = n, AFS_FS = n, AUTOFS4_FS = n, CEPH_FS = n, CIFS = n, CODA_FS = n, FUSE_FS = n, GFS2_FS = n, NCP_FS = n, NFSD = n, NFS_FS = n, OCFS2_FS = n, XFS_FS = n
+
**** Security options - Grsecurity - GRKERNSEC = n (if applicable)
+
  
** As of 3.10.xx kernel, all of the above options are safe to use with User namespaces, except for XFS_FS, therefore with kernel >=3.10.xx, you should answer XFS_FS = n, if you want User namespaces support.
+
==== Enabling IPv6 on Your Router ====
** in your kernel source directory, you should check init/Kconfig and find out what UIDGID_CONVERTED depends on
+
  
==== Kernel configuration ====
+
If you have a router that is capable of supporting IPv6, then it is possible to configure your router so that an IPv6 network is available, at which point you can simply configure your Funtoo Linux system to participate in it. Note that many popular home/office routers can be configured to use an IPv6 over IPv4 tunnel, which provides a convenient option for home networks or smaller organizations to participate in IPv6. Using this approach, your computer systems behind the router are simply configured to participate in an IPv6 network, and your router handles tunneling the IPv6 traffic back and forth between your tunnel provider. This is typically the most flexible option for exploring IPv6 as it allows you to have multiple computer systems in your home or office to participate in an IPv6 network while your router takes care of everything transparently.
These options should be enable in your kernel to be able to take full advantage of LXC.
+
  
* General setup
+
==== Using Unique Local IPv6 Unicast Addresses ====
** CONFIG_NAMESPACES
+
*** CONFIG_UTS_NS
+
*** CONFIG_IPC_NS
+
*** CONFIG_PID_NS
+
*** CONFIG_NET_NS
+
*** CONFIG_USER_NS
+
** CONFIG_CGROUPS
+
*** CONFIG_CGROUP_DEVICE
+
*** CONFIG_CGROUP_SCHED
+
*** CONFIG_CGROUP_CPUACCT
+
*** CONFIG_CGROUP_MEM_RES_CTLR (in 3.6+ kernels it's called CONFIG_MEMCG)
+
*** CONFIG_CGROUP_MEM_RES_CTLR_SWAP (in 3.6+ kernels it's called CONFIG_MEMCG_SWAP)
+
*** CONFIG_CPUSETS (on multiprocessor hosts)
+
* Networking support
+
** Networking options
+
*** CONFIG_VLAN_8021Q
+
* Device Drivers
+
** Character devices
+
*** Unix98 PTY support
+
**** CONFIG_DEVPTS_MULTIPLE_INSTANCES
+
** Network device support
+
*** Network core driver support
+
**** CONFIG_VETH
+
**** CONFIG_MACVLAN
+
  
Once you have lxc installed, you can then check your kernel config with:
+
If you don't have public IPv6 connectivity or you don't wish to open an IPv6 tunnel over an IPv4 network, you can use a mechanism similar to IPv4 private addresses ranges. This mechanism consists of concatenating the prefix FC00::/7 with a globally unique identifier and a subnet identifier to form the upper 64 bits of the IPv6 address. Details of the mechanisms to forge a unique local IPv6 unicast address are documented in [http://tools.ietf.org/html/rfc4193 RFC 4193], however unique local IPv6 unicast addresses are made of the following components:
<console>
+
# ##i##CONFIG=/path/to/config /usr/sbin/lxc-checkconfig
+
</console>
+
  
=== Emerge lxc ===
+
<pre>
<console>
+
      | 7 bits |1|  40 bits  |  16 bits  |          64 bits          |
# ##i##emerge -av app-emulation/lxc
+
      +--------+-+------------+-----------+----------------------------+
</console>
+
      | Prefix |L| Global ID  | Subnet ID |        Interface ID        |
=== Configure Networking For Container ===
+
      +--------+-+------------+-----------+----------------------------+
 +
</pre>
  
Typically, one uses a bridge to allow containers to connect to the network. This is how to do it under Funtoo Linux:
+
* Prefix (7 bits): always FC00::/7
 +
* L (1 bits): must be set to 1 (1 = prefix is locally assigned, 0 is undefined so far and must not be used)
 +
* Global ID: A random identifier (see [http://tools.ietf.org/html/rfc4193 RFC 4193] for details about the generation algorithm
 +
* Interface ID: Host interface ID as defined in [http://tools.ietf.org/html/rfc3513 RFC 3513]
  
# create a bridge using the Funtoo network configuration scripts. Name the bridge something like <tt>brwan</tt> (using <tt>/etc/init.d/netif.brwan</tt>). Configure your bridge to have an IP address.
+
{{Note}}Just like with private IPv4 addresses, an IPv6 router must not route a unique local IPv6 unicast address outside the organization local network.
# Make your physical interface, such as <tt>eth0</tt>, an interface with no IP address (use the Funtoo <tt>interface-noip</tt> template.)
+
# Make <tt>netif.eth0</tt> a slave of <tt>netif.brwan</tt> in <tt>/etc/conf.d/netif.brwan</tt>.
+
# Enable your new bridged network and make sure it is functioning properly on the host.
+
  
You will now be able to configure LXC to automatically add your container's virtual ethernet interface to the bridge when it starts, which will connect it to your network.
+
==== ICMPv6 ====
  
== Setting up a Funtoo Linux LXC Container ==
+
Some network administrators are pretty aggressive with ICMP filtering on their networks. Do not misunderstand us: ICMP is an integral part of the TCP/IP protocol stack and a necessary gear for its correct operation. ICMP messages are even more fundamental in IPv6 because some TCP/IP core mechanisms like have been replaced by ICMPv6 messages: ARP is no longer in use in an IPv6 world, instead a set of of ICMPv6 messages have been created to assume the same functionality (''Neighbor Discovery Protocol'' or ''NDP'').  Also no fragmentation can be done in IPv6 and blocking ICMPv6 messages like ''Packet too big'' is not a good idea. In general: '''do not block any other ICMPv6 messages than ''echo request'' and ''echo reply'' '''.
  
Here are the steps required to get Funtoo Linux running <i>inside</i> a container. The steps below show you how to set up a container using an existing Funtoo Linux OpenVZ template. It is now also possible to use [[Metro]] to build an lxc container tarball directly, which will save you manual configuration steps and will provide an <tt>/etc/fstab.lxc</tt> file that you can use for your host container config. See [[Metro Recipes]] for info on how to use Metro to generate an lxc container.
+
=== Stateful vs stateless ===
  
=== Create and Configure Container Filesystem ===
+
There are several ways to assign IPv6 addresses on a network :
 +
* Stateful: a DHCPv6 server is responsible of leasing and following all assigned IPv6 addresses. It works the same way of the well known traditional DHCP with some minor variations but the idea beneath is exactly the same.
 +
* Stateless: Nothing leases or tracks assigned IPv6 addresses on the network. Instead, machines use either an IPv6 address manually entered by the network administrator either a combo of Router Advertisement messages with a magic calculation of their network adapter's MAC address (EUI-64).
  
# Start with a Funtoo LXC template, and unpack it to a directory such as <tt>/lxc/funtoo0/rootfs/</tt>
+
= Requirements =
# Create an empty <tt>/lxc/funtoo0/fstab</tt> file
+
# Ensure <tt>c1</tt> line is uncommented (enabled) and <tt>c2</tt> through <tt>c6</tt> lines are disabled in <tt>/lxc/funtoo0/rootfs/etc/inittab</tt>
+
  
That's almost all you need to get the container filesystem ready to start.
+
IPv6 requires CONFIG_IPV6 to be enabled in your kernel (either compiled in or as a module). If compiled as a module (e.g. if your kernel was compiled by genkernel), ensure the module is loaded.
 +
<console>
 +
###i## lsmod | grep ipv6
 +
</console>
  
=== Create Container Configuration Files ===
+
If this returns nothing, load the module with:
 
+
Create the following files:
+
 
+
==== <tt>/lxc/funtoo0/config</tt> ====
+
 
+
 
+
and also create symlink from
+
==== <tt> /lxc/funtoo0/config to /etc/lxc/funtoo0.conf </tt> ====
+
 
<console>
 
<console>
###i## ln -s /lxc/funtoo0/config /etc/lxc/funtoo0.conf
+
###i## modprobe ipv6
 
</console>
 
</console>
  
{{fancynote|Daniel Robbins needs to update this config to be more in line with http://wiki.progress-linux.org/software/lxc/ -- this config appears to have nice, refined device node permissions and other goodies. // note by Havis to Daniel, this config is already superior.}}
+
= Commands =
  
 +
; ping6
 +
: IPv6 ping command
 +
; route -6
 +
: show IPv6 routes
 +
; ip -6 neigh show
 +
: show all IPv6 neighbors on the local LAN
  
Read "man 5 lxc.conf" , to get more information about linux container configuration file.
+
= Configuration =
<pre>
+
## Container
+
lxc.utsname                            = funtoo0
+
lxc.rootfs                              = /lxc/funtoo0/rootfs/
+
lxc.arch                                = x86_64
+
#lxc.console                            = /var/log/lxc/funtoo0.console  # uncomment if you want to log containers console
+
lxc.tty                                = 6  # if you plan to use container with physical terminals (eg F1..F6)
+
#lxc.tty                                = 0  # set to 0 if you dont plan to use the container with physical terminal, also comment out in your containers /etc/inittab  c1 to c6 respawns (e.g. c1:12345:respawn:/sbin/agetty 38400 tty1 linux)
+
lxc.pts                                = 1024
+
  
 +
== Participating in an Existing IPv6 Network ==
  
## Capabilities
+
If your local network already supports IPv6, then you can simply configure Funtoo Linux to participate in this IPv6 network. Here is a sample configuration that might be used to configure an ethernet interface (netif.eth0) to participate in both an IPv4 and IPv6 network:
lxc.cap.drop                            = audit_control
+
lxc.cap.drop                            = audit_write
+
lxc.cap.drop                            = mac_admin
+
lxc.cap.drop                            = mac_override
+
lxc.cap.drop                            = mknod
+
lxc.cap.drop                            = setfcap
+
lxc.cap.drop                            = setpcap
+
lxc.cap.drop                            = sys_admin
+
lxc.cap.drop                            = sys_boot
+
#lxc.cap.drop                            = sys_chroot # required by SSH
+
lxc.cap.drop                            = sys_module
+
#lxc.cap.drop                            = sys_nice
+
lxc.cap.drop                            = sys_pacct
+
lxc.cap.drop                            = sys_rawio
+
lxc.cap.drop                            = sys_resource
+
lxc.cap.drop                            = sys_time
+
#lxc.cap.drop                            = sys_tty_config # required by getty
+
  
## Devices
+
{{File
#lxc.cgroup.devices.allow              = a # Allow access to all devices
+
|/etc/netif.d/netif.eth0|<pre>
lxc.cgroup.devices.deny                = a # Deny access to all devices
+
template="interface"
 +
ipaddr="10.0.1.200/24 2001:470:d:c2c:218:51ff:feea:ee21/64"
 +
gateway="10.0.1.1"
 +
nameservers="10.0.1.1 2001:470:20::2"
 +
domain="funtoo.org"
 +
multicast="yes"
 +
routes="2000::/3 via fe80::daa2:5eff:fe7a:83de dev eth0"
 +
</pre>}}
  
# Allow to mknod all devices (but not using them)
+
Above, we use the <tt>interface</tt> template, and specify both an IPv4 and IPv6 address (with network mask) for <tt>ipaddr</tt>. In addition, an IPv4 and IPv6 nameserver is specified. For routing, we use the <tt>gateway</tt> command to specify an IPv4 gateway, while we use the <tt>routes</tt> command to specify a route to our router, which in this case has address <tt>fe80::daa2:5eff:fe7a:83de</tt> and is reachable on device eth0.
lxc.cgroup.devices.allow                = c *:* m
+
lxc.cgroup.devices.allow                = b *:* m
+
  
lxc.cgroup.devices.allow                = c 1:3 rwm # /dev/null
+
Note that we specify a route for "2000::/3" rather than "::/0" or "default", and this is a bit unusual. This is to work around a bug in many Linux kernels that prevents the default route from being handled properly. "2000::/3" maps to all routable IP addresses and has the benefit of being compatible with all Linux kernels.
lxc.cgroup.devices.allow                = c 1:5 rwm # /dev/zero
+
lxc.cgroup.devices.allow                = c 1:8 rwm # /dev/random
+
lxc.cgroup.devices.allow                = c 1:9 rwm # /dev/urandom
+
#lxc.cgroup.devices.allow                = c 4:0 rwm # /dev/tty0 ttys not required if you have lxc.tty = 0
+
#lxc.cgroup.devices.allow                = c 4:1 rwm # /dev/tty1 devices with major number 4 are "real" tty devices
+
#lxc.cgroup.devices.allow                = c 4:2 rwm # /dev/tty2
+
#lxc.cgroup.devices.allow                = c 4:3 rwm # /dev/tty3
+
lxc.cgroup.devices.allow                = c 5:0 rwm # /dev/tty
+
lxc.cgroup.devices.allow                = c 5:1 rwm # /dev/console
+
lxc.cgroup.devices.allow                = c 5:2 rwm # /dev/ptmx
+
lxc.cgroup.devices.allow                = c 10:229 rwm # /dev/fuse
+
lxc.cgroup.devices.allow                = c 136:* rwm # /dev/pts/* devices with major number 136 are pts
+
lxc.cgroup.devices.allow                = c 254:0 rwm # /dev/rtc0
+
  
## Limits#
+
=== Many Addresses and Stateless Autoconfiguration ===
lxc.cgroup.cpu.shares                  = 1024
+
lxc.cgroup.cpuset.cpus                = 0        # limits container to CPU0
+
lxc.cgroup.memory.limit_in_bytes      = 512M
+
lxc.cgroup.memory.memsw.limit_in_bytes = 1G
+
#lxc.cgroup.blkio.weight                = 500      # requires cfq block scheduler
+
  
## Filesystem
+
Also note that if we did not specify an IPv6 address in the <tt>ipaddr</tt> variable, then eth0 would still get at least one IPv6 address anyway. First, it would get a link-local address, starting in <tt>fe80::/16</tt>, and it would also automatically use ''stateless autoconfiguration'' to grab an unused IPv6 address from the range used by your IPv6 router. This works similarly to the way a DHCP client works with IPv4, but is built-in to the IPv6 protocol and does not require a DHCP server to function. It works because with IPv6, routers send out ICMP packets to advertise themselves to systems on your network, and your Funtoo Linux system can use this information to automatically grab an unused address. It is important to understand this behavior because it means that by default, your Funtoo Linux system will grab a globally-routable ("public") IPv6 address from your router with no steps necessary on your part and thus may be accessible from the Internet if no firewall is in place. However, in most cases the default IPv6 route must be specified in the <tt>routes</tt> variable for IPv6 to function properly, so this auto-configuration isn't completely automatic at this time.
#containers fstab should be outside it's rootfs dir (e.g. /lxc/funtoo0/fstab is ok, but /lxc/funtoo0/rootfs/etc/fstab is wrong!!!)
+
#lxc.mount                              = /lxc/funtoo0/fstab     
+
  
#lxc.mount.entry is prefered, because it supports relative paths
+
== Local IPv6 over IPv4 Tunnelling ==
lxc.mount.entry                        = proc proc proc nosuid,nodev,noexec  0 0
+
lxc.mount.entry                        = sysfs sys sysfs nosuid,nodev,noexec,ro 0 0
+
lxc.mount.entry                        = devpts dev/pts devpts nosuid,noexec,mode=0620,ptmxmode=000,newinstance 0 0
+
lxc.mount.entry                        = tmpfs dev/shm tmpfs nosuid,nodev,mode=1777 0 0
+
lxc.mount.entry                        = tmpfs run tmpfs nosuid,nodev,noexec,mode=0755,size=128m 0 0
+
lxc.mount.entry                        = tmpfs tmp tmpfs nosuid,nodev,noexec,mode=1777,size=1g 0 0
+
  
##Example of having /var/tmp/portage as tmpfs in container
+
Tunnelling is the process of encapsulating IPv6 packets within an IPv4 packet so that it can be transmitted over an IPv4 network. This process happens at a local ''tunnel entry point'', which can be a Linux machine or a router, such as an Apple AirPort. The packet then traverses the IPv4 network, until reaches the ''tunnel endpoint'', which ''de-encapsulates'' the packet and places it on an IPv6 network. There are several different types of IPv6 tunnels. There are also several IPv6 tunnel providers that offer free tunnelling services, making it convenient to start using IPv6, even on your home network.
#lxc.mount.entry                         = tmpfs var/tmp/portage tmpfs defaults,size=8g,uid=250,gid=250,mode=0775 0 0
+
##Example of bind mount
+
#lxc.mount.entry                        = /srv/funtoo0 /lxc/funtoo0/rootfs/srv/funtoo0 none defaults,bind 0 0
+
  
## Network
+
Note that if you want configure an IPv6 over IPv4 tunnel on your router, such as an Apple AirPort, then you will simply need to sign up with one of the tunnel providers and use their instructions to configure your router. At this point, your router will be IPv6 enabled and you can then configure your Funtoo Linux system to participate in an existing IPv6 network using the instructions in the previous section. If this is not an option for you, then it is also possible to set up the IPv6 over IPv4 tunnel directly on your Funtoo Linux system. This means that only your Funtoo Linux system will be able to participate in IPv6, at least to start (later, you could configure your Funtoo Linux system to route IPv6 for other machines on your network) Follow the instructions in this section to set up local tunneling on your Funtoo Linux system.
lxc.network.type                        = veth
+
lxc.network.flags                      = up
+
lxc.network.hwaddr                      = #put your MAC address here, otherwise you will get a random one
+
lxc.network.link                        = br0
+
lxc.network.name                        = eth0
+
#lxc.network.veth.pair                  = veth-example
+
</pre>
+
  
Read "man 7 capabilities" to get more information aboout Linux capabilities.
+
=== Tunnel providers ===
 +
; [http://gogonet.gogo6.com/page/freenet6-tunnelbroker freenet6]
 +
: Supports anonymous tunnels and works behind NAT. You can connect to with your login or as anonymous from anywhere. This can be configured under Funtoo Linux by emerging the '''net-misc/gogoc''' ebuild.
 +
; [http://tunnelbroker.net/ Hurricane Electric]
 +
: Configured '''6in4''' tunnel, with support for dynamic IPv4 addresses, and Apple AirPorts can be configured to use this tunnel - see [http://www.nedprod.com/Niall_stuff/addingIPv6toyourhome.html this link]. Also see [http://ipv6.he.net/certification/faq.php ipv6.he.net FAQ] You can setup this tunnel with ifconfig and iproute2, or configure your router to be the tunnel entry point  -- the point at which IPv6 traffic is encapsulated/de-encapsulated.
 +
; [http://en.wikipedia.org/wiki/Teredo_tunneling Teredo]/[http://www.remlab.net/miredo/ Miredo]
 +
: [http://tools.ietf.org/html/rfc4380 RFC4380] mandated transition mechanism. Works behind NAT. Assigns one "/128" per host.
  
Above, use the following command to generate a random MAC for <tt>lxc.network.hwaddr</tt>:
+
=== Getting Started with gogoc ===
  
<pre>
+
Freenet6 is a free IPv6 access service provided by gogo6 via the [http://en.wikipedia.org/wiki/Tunnel_Setup_Protocol TSP tunnelling protocol].
# openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
+
<code>gogoc</code> supports any TSP tunnel; perhaps one is provided by your ISP. We will focus on an anonymous tunnel via freenet6.
</pre>
+
  
It is a very good idea to assign a static MAC address to your container using <tt>lxc.network.hwaddr</tt>. If you don't, LXC will auto-generate a new random MAC every time your container starts, which may confuse network equipment that expects MAC addresses to remain constant.
+
You need ipv6 to be enabled in your kernel as well as the TUN module.
  
It might happen from case to case that you aren't able to start your LXC Container with the above generated MAC address so for all these who run into that problem here is a little script that connects your IP for the container with the MAC address. Just save the following code as <tt>/etc/lxc/hwaddr.sh</tt>, make it executable and run it like <tt>/etc/lxc/hwaddr.sh xxx.xxx.xxx.xxx</tt> where xxx.xxx.xxx.xxx represents your Container IP.
+
You can quickly get started by emerging {{Package|net-misc/gogoc}}, adding <code>gogoc</code> to your startup scripts and starting it.
 +
{{Package|net-misc/gogoc}} is currently keyworded unstable (on some architectures, see [https://bugs.gentoo.org/362549 gentoo bug #362549]). If you are running stable Funtoo, you may want to put an entry into your package.keywords/package.accept_keywords file.
 +
<console>
 +
###i## emerge gogoc
 +
###i## bzcat /usr/share/doc/gogoc-*/gogoc.conf.sample.bz2 >/etc/gogoc/gogoc.conf
 +
###i## rc-update add gogoc default
 +
###i## /etc/init.d/gogoc start
 +
</console>
  
<pre>
+
{{Note}}By default, <code>gogoc</code> will use an anonymous tunnel. If you wish to authenticate yourself, read and edit <code>/etc/gogoc/gogoc.conf</code>.
#!/bin/sh
+
IP=$*
+
HA=`printf "02:00:%x:%x:%x:%x" ${IP//./ }`
+
echo $HA
+
</pre>
+
  
==== <tt>/lxc/funtoo0/fstab</tt> ====
+
=== Getting started with Teredo ===
Note: it is now preferable to have mount entries directly in config file instead of separate fstab
+
 
+
<pre>
+
none /lxc/funtoo0/dev/pts devpts defaults 0 0
+
none /lxc/funtoo0/proc proc defaults 0 0
+
none /lxc/funtoo0/sys sysfs defaults 0 0
+
none /lxc/funtoo0/dev/shm tmpfs nodev,nosuid,noexec,mode=1777,rw 0 0
+
</pre>
+
 
+
== LXC Networking ==
+
  
 +
While this mechanism is officially called Teredo, the implementation of the Teredo service we will be using is called Miredo.
 +
{{Note}}{{Package|net-misc/miredo}} is currently keyworded unstable. If you are running stable Funtoo, you may want to put an entry into your package.keywords/package.accept_keywords file.}}
  
 +
Emerge <tt>net-misc/miredo</tt> and start it up (you can add it to your default runlevel if you wish):
 +
<console>
 +
###i## emerge net-misc/miredo
 +
###i## /etc/init.d/miredo start
 +
</console>
  
*veth - Virtual Ethernet (bridge)
+
{{Note}}Miredo requires <code>CONFIG_TUN</code> enabled in your kernel. If it is compiled as a module, ensure the <tt>tun</tt> module is loaded.
*vlan - vlan interface (requires device able to do vlan tagging)
+
*macvlan (mac-address based virtual lan tagging) has 3 modes:
+
**private
+
**vepa (Virtual Ethernet Port Aggregator)
+
**bridge
+
*phys - dedicated host NIC
+
[https://blog.flameeyes.eu/2010/09/linux-containers-and-networking Linux Containers nad Networking]
+
  
Enable routing on the host:
+
If all goes well, you can check the assignment of an IPv6 address using <tt>/sbin/ip</tt>, for example:
By default Linux workstations and servers have IPv4 forwarding disabled.
+
 
<console>
 
<console>
# echo "1" > /proc/sys/net/ipv4/ip_forward
+
###i## /sbin/ip addr show dev teredo
# cat /proc/sys/net/ipv4/ip_forward
+
4: teredo: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc pfifo_fast state UNKNOWN qlen 500
# 1
+
    link/none
#
+
    inet6 2001:0:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/32 scope global
 +
      valid_lft forever preferred_lft forever
 +
    inet6 fe80::ffff:ffff:ffff/64 scope link
 +
      valid_lft forever preferred_lft forever
 
</console>
 
</console>
  
== Initializing and Starting the Container ==
+
=== Tunnelling 6to4 ===
  
You will probably need to set the root password for the container before you can log in. You can use chroot to do this quickly:
+
6to4 is an Internet transition mechanism for migrating from IPv4 to IPv6, a system that allows IPv6 packets to be transmitted over an IPv4 network (generally the IPv4 Internet) without the need to configure explicit tunnels.
 +
When using 6to4 your IPv6 golablly addressable IP is generated from you IPv4 IP address.
  
<pre>
+
The anycast address of 192.88.99.1 has been allocated for the purpose of sending packets to a 6to4 relay router. Note that when converted to a 6to4 IPv6 address with the subnet and hosts fields set to zero this IPv4 address (192.88.99.1) becomes the IPv6 address 2002:c058:6301::.
# chroot /lxc/funtoo0/rootfs
+
(chroot) # passwd
+
New password: XXXXXXXX
+
Retype new password: XXXXXXXX
+
passwd: password updated successfully
+
# exit
+
</pre>
+
 
+
Now that the root password is set, run:
+
  
 +
To use the funtoo network template method, write the config file for the interface /etc/conf.d/netif.6to4 (which will also handle the converting of your IPv4 address to your IPv6 address). Make sure you change "WAN" to your correct internet facing interface.
 
<pre>
 
<pre>
# lxc-start -n funtoo0 -d
+
template=ipv6-tunnel
 +
WAN="eth0"
 +
MTU="1280"
 +
ipv4=`ifconfig $WAN | sed -ne 's/[[:space:]]*inet addr:\([0-9.]*\).*/\1/p'`
 +
ipv6=`printf "2002:%02x%02x:%02x%02x::1" \`echo $ipv4 | tr "." " "\``
 +
remote=192.88.99.1
 +
local="$ipv4/24"
 +
ipaddr="$ipv6/48"
 +
routes="2000::/3 via 2002:c058:6301:: dev $WAN"
 
</pre>
 
</pre>
  
The <tt>-d</tt> option will cause it to run in the background.
+
Then create the netif.6to4 symlink and add it to the default runlevel
 +
<console>
 +
###i## ln -s /etc/init.d/netif.tmpl /etc/init.d/netif.6to4
 +
###i## rc-update add netif.6to4 default
 +
###i## /etc/init.d/netif.6to4 start
 +
</console>
  
To attach to the console:
+
You should now be capable of connecting via IPv6:
 +
<console>
 +
###i## ping6 ipv6.google.com
 +
</console>
  
<pre>
+
To allow this host to be a router, a modified template is required:
# lxc-console -n funtoo0
+
{{File
</pre>
+
|/etc/netif.d/ipv6-tunnel|<pre>
 +
#!/bin/sh
  
You should now be able to log in and use the container. In addition, the container should now be accessible on the network.
+
netif_pre_up() {
 +
        require local remote
 +
        try ip tunnel add $interface mode sit remote $remote local $local ttl 255
 +
        try ip addr add $ipaddr dev $interface
 +
        try ip addr add $ipaddr4 dev $interface
 +
}
  
To directly attach to container:
+
netif_post_up() {
 +
        try ip route add ::/0 dev $interface
 +
}
  
<pre>
+
netif_pre_down() {
# lxc-attach -n funtoo0
+
        ip route del ::/0 dev $interface
</pre>
+
}
  
To stop the container:
+
netif_post_down() {
 +
        ip tunnel del $interface
 +
}
 +
</pre>}}
  
<pre>
+
Then add the following line to <tt>/etc/conf.d/netif.6to4</tt>:
# lxc-stop -n funtoo0
+
{{File
</pre>
+
|/etc/conf.d/netif.6to4|<pre>
 +
ipaddr4="$ipv4/24"
 +
</pre>}}
  
Ensure that networking is working from within the container while it is running, and you're good to go!
+
After restarting the 6to4 interface radvd can be started:
 
+
== Starting LXC container during host boot ==
+
 
+
# You need to create symlink in /etc/init.d/ to /etc/init.d/lxc, so that it reflects your container.
+
# ln -s /etc/init.d/lxc /etc/init.d/lxc.funtoo0
+
# now you can add lxc.funtoo0 to default runlevel
+
# rc-update add lxc.funtoo0 default
+
 
<console>
 
<console>
# rc
+
###i## /etc/init.d/netif.6to4 restart
# * Starting funtoo0 ...                 [ ok ]
+
###i## /etc/init.d/radvd start
 
</console>
 
</console>
  
== LXC Bugs/Missing Features ==
+
== Optimization ==
 
+
This section is devoted to documenting issues with the current implementation of LXC and its associated tools. We will be gradually expanding this section with detailed descriptions of problems, their status, and proposed solutions.
+
 
+
=== reboot ===
+
 
+
By default, lxc does not support rebooting a container from within. It will simply stop and the host will not know to start it.
+
 
+
=== PID namespaces ===
+
 
+
Process ID namespaces are functional, but the container can still see the CPU utilization of the host via the system load (ie. in <tt>top</tt>).
+
 
+
=== /dev/pts newinstance ===
+
 
+
* Some changes may be required to the host to properly implement "newinstance" <tt>/dev/pts</tt>. See [https://bugzilla.redhat.com/show_bug.cgi?id=501718 This Red Hat bug].
+
 
+
=== lxc-create and lxc-destroy ===
+
 
+
* LXC's shell scripts are badly designed and are sure way to destruction, avoid using lxc-create and lxc-destroy.
+
 
+
=== network initialization and cleanup ===
+
  
* If used network.type = phys after lxc-stop the interface will be renamed to value from lxc.network.link. It supposed to be fixed in 0.7.4, happens still on 0.7.5 - http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg01760.html
+
=== Prefer IPv4 over IPv6 ===
  
* Re-starting a container can result in a failure as network resource are tied up from the already-defunct instance: [http://www.mail-archive.com/lxc-devel@lists.sourceforge.net/msg00824.html]
+
Generally if your IPv6 connection is through a tunnel, it will be slower than an IPv4 connection. For this reason, if you are using an IPv6 tunnel, it can be best to configure your systems to ''prefer'' IPv4 if an IPv4 version of the site is available, and use IPv6 only when necessary. This way, you will avoid unnecessary encapsulation and de-encapsulation of IPv4 traffic. Here's how to do this for a number of operating systems:
  
=== lxc-halt ===
+
==== Linux ====
  
* Missing tool to graceful shutdown container. 'lxc-halt' should be written and be posix sh-compatible, using lxc-execute to run halt in container.
+
Linux will prefer IPv6 if IPv6 support is enabled in the kernel. To prefer IPv4, edit <tt>/etc/gai.conf</tt> and add this line:
 +
{{File
 +
|/etc/gai.conf|<pre>
 +
precedence ::ffff:0:0/96 100
 +
</pre>}}
  
=== funtoo ===
+
==== Windows 7, Server 2008, Vista ====
  
* Our udev should be updated to contain <tt>-lxc</tt> in scripts. (This has been done as of 02-Nov-2011, so should be resolved. But not fixed in our openvz templates, so need to regen them in a few days.)
+
These operating systems prefer IPv6 by default. See [http://msdn.microsoft.com/en-us/library/bb756941.aspx this link]. To prefer IPv4, use the following steps:
* Our openrc should be patched to handle the case where it cannot mount tmpfs, and gracefully handle this situation somehow. (Work-around in our docs above, which is to mount tmpfs to <tt>/libexec/rc/init.d</tt> using the container-specific <tt>fstab</tt> file (on the host.)
+
* Emerging udev within a container can/will fail when realdev is run, if a device node cannot be created (such as /dev/console) if there are no mknod capabilities within the container. This should be fixed.
+
  
== References ==
+
# Start <tt>regedit</tt>.
 +
# Navigate to <tt>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\TCPIP6\Parameters</tt>.
 +
# Create a new DWORD named <tt>DisabledComponents</tt>. Edit this new DWORD and set it to HEX value of <tt>20</tt> or a DECIMAL value of <tt>32</tt>.
 +
# Restart your computer.
  
* <tt>man 7 capabilities</tt>
+
== ISPs who currently have IPv6 enabled for residential customers ==
* <tt>man 5 lxc.conf</tt>
+
  
== Links ==
+
* Canada:
 +
** '''Videotron''': Videotron has a [http://support.videotron.com/residential/internet/ipv6/videotron-ipv6 beta-program] for residential customers who want to test IPv6 (no official technical support, it is possible they don't have enabled it in your area so check first before investing in new hardware). Although  at date of writing, a large part of their networks are IPv6, '''you must go through a 6rd tunnel''' because they still need to upgrade some of their equipments and '''your router must support the 6rd protocol''' (this requirement is documented). Videotron sells you a D-Link DIR-825 with a modified firmware however this model has a weird gotcha: it does not support IPv6 firewalling.''' This is not a Videotron specific issue''' (even the genuine firmwares coming  from the manufacturer has no support for IPv6 firewalling as of June 2011). A good alternative to recommend is the CISCO/LinkSYS E4200, more expensive (MSRP ~$180 US/CDN) but has IPv6 firewalling support.  Once the E4200 firmware has been upgraded go in Setup/IPv6 Setup disable "IPv6 - Automatic" (you should then see an IPv6 address in the DUID field) and leave "automatic" for the 6rd configuration. You should be in business and see all of the hosts on your network with an IPv6 stack enabled being assigned a public IPv6 address starting with 2607:f048.
 +
** '''Teksavvy''' : TekSavvy has a [http://teksavvy.com/ipv6 IPv6 beta-program] for residential customers who use their DSL service (no statement found for cable connections). Just ask them to enable IPv6 to your subscription and it should be available within the next 24 hours. Their IPv6 connectivity is native so you don't need to setup a tunnel.
 +
** '''Shaw''' (?)
 +
** '''Cogeco cable''' (?)
 +
** '''Telus''' (?)
 +
** '''Bell''' : Bell appears to have an official IPv6 support especially for its business subscribers (See http://ipv6.bell.ca) via a toolkit and various web pages on the subject.
  
* There are a number of additional lxc features that can be enabled via patches: [http://lxc.sourceforge.net/patches/linux/3.0.0/3.0.0-lxc1/]
+
* France
* [https://wiki.ubuntu.com/UserNamespace Ubuntu User Namespaces page]
+
** '''Free'''
* lxc-gentoo setup script [https://github.com/globalcitizen/lxc-gentoo on GitHub]
+
** '''Nerim'''
 +
** '''the French Data Network (FDN)'''
 +
* United States:
 +
** '''Comcast''' (limited pilot in some areas only)
  
* '''IBM developerWorks'''
+
== Home routers compatible with IPv6 ==
** [http://www.ibm.com/developerworks/linux/library/l-lxc-containers/index.html LXC: Linux Container Tools]
+
** [http://www.ibm.com/developerworks/linux/library/l-lxc-security/ Secure Linux Containers Cookbook]
+
  
* '''Linux Weekly News'''
+
A few residential routers have support for IPv6 at date of writing and many more home networking devices will have robust IPv6 support in a more or less near futures. The following does not pretend to be exhaustive:
** [http://lwn.net/Articles/244531/ Smack for simplified access control]
+
* '''D-Link DIR-825 rev. 1B''' (June 2011): Has IPv6 support out of the box, however for somewhat reason the router has no support for IPv6 firewalling even with teh 2.05N revision of the firmware. Consequence for you is you have to deploy an IPv6 firewall on each of hosts concerned with a public IPv6 connectivity. The canadian ISP Videotron is selling a DIR-825 with a customized firmware as unfortunately, like with the genuine manufacturer firmware, no IPv6 firewalling possible :( .
 +
* '''CISCO/LinkSys E4200''' (June 2011): Advertised as being IPv6 compatible with a firmware update (available as of June 14th 2011 -> check for the version tagged 1.0.02 build 13 or later on the manufacturer website). The device supports native IPv6 and IPv6 through a 6rd tunnel (no support for any other tunneling protocol).
  
[[Category:Labs]]
+
== Resources ==
 +
*[http://ipv6.he.net/certification/cert-main.php free ipv6 certification program]
 +
*[http://ipv6-test.com/ Test ipv6 (ipv6-test.com)]
 +
*[http://test-ipv6.com/ Test ipv6 (test-ipv6.com)]
 +
*[http://www.comcast6.net/ Comcast's IPv6 page]
 +
*[http://tunnelbroker.net/ Hurricane Electric Tunnel Broker ]
 +
*[http://www.gentoo-wiki.info/HOWTO_IPv6 Gentoo Wiki IPv6 ]
 +
*[http://www.gentoo.org/doc/en/ipv6.xml Gentoo IPv6 Guide]
 +
with Apple airport extreme, etc:
 +
*[http://www.tunnelbroker.net/forums/index.php?topic=680.0 tunnelbroker.net forums post - airport config ]
 +
*[http://www.nedprod.com/Niall_stuff/addingIPv6toyourhome.html Adding IPv6 Support To Your Home]
 +
*[http://www.tunnelbroker.net/forums/index.php?topic=273.0 tunnelbroker.net forums post - Gentoo config (won't work in Funtoo)]
 +
Nice Overview over IPv6
 +
* [http://www.linux.com/learn/tutorials/428331-ipv6-crash-course-for-linux IPv6 Crash Course for Linux] and page 2 [http://www.linux.com/learn/tutorials/432537:another-ipv6-crash-course-for-linux-real-ipv6-addresses-routing-name-services IPv6 Crash Course for routing name services]
 +
* [http://livre.g6.asso.fr/index.php/Accueil IPv6 Théorie et Pratique (in french only)] revised online version of the O'Reilly book published in 2005 by a collective researchers and IT actors.
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
[[Category:Virtualization]]
+
[[Category:Networking]]
 +
[[Category:Featured]]

Revision as of 21:08, 28 January 2014

Contents

Introduction

IPv6 is an redesigned and improved version of the IPv4 protocol, and is intended to start replacing IPv4 in 2011 and beyond as the IPv4 global address space becomes exhausted. IPv6 includes a number of improvements over IPv4, including most notably 128-bit addressing, simplified protocol header, integrated IPSec and Multicast implementations, improved discovery, flexibility and router interaction, and improved facilities for auto-configuration. IPv6 also marks the end of Network Address Translation (NAT), which is not recommended or necessary with IPv6. While it's possible to use non-routable addresses with IPv6, this is not a requirement and it is possible for any IPv6 device to have its own globally routable IP address if desired.

Addressing

IPv6 addresses consist of 128 bits. The first 64 bits are used for the network and subnet portion of the address, while the remaining 64 bits are used for the host portion of the address. For more information on how to represent IPv6 addresses, please see the Presentation section of the IPv6 address page on Wikipedia.

Network Masks

IPv6 addresses also have an associated network mask, which is typically written as a trailing "/64" or "/48" at the end of the address, which specifies what bits of the address are used for network and subnet parts. For example, a "/48" mask specifies that addresses use a 48-bit network part, followed by a 16-bit subnet part (allowing for 2^16 subnets), followed by a 64-bit host part (allowing for up to 264 hosts for each of the 216 subnets to be specified.) In contrast, a "/64" mask specifies that addresses use a 64-bit network part, no subnet part, and a 64-bit host part (allowing up to 264 hosts total to be specified.) This means that if you are issued a "/64" set of addresses, you will not be able to define any subnets, but if you are issued a "/48" set of addresses, you will be able to define up to 216 subnets.

Address Space and Security

IPv6 also uses a global, flat address space. IPv6 is designed so that any device that needs to communicate on the Internet is able to have a unique globally-routable address. With IPv6, there is no need for using Network Address Translation (NAT). With IPv4, NAT is often used as a means of protecting systems from being accessed by malicious users. With IPv6, firewalls are typically used instead of NAT for restricting access to systems. With IPv6, it is normal for all machines on your home network to have "globally routable" addresses, the equivalent of a "public IP" in the world of IPv4. It is important to understand that this is the way that IPv6 is intended to be used for the majority of users, and that an IPv6-enabled router will no longer be performing NAT for you.

Using IPv6

There are several ways to use IPv6 with Funtoo Linux. Here are some possibilities:

  • Participating in an existing IPv6 network
  • Creating a local IPv6 over IPv4 tunnel
  • Enabling IPv6 on your router, possibly via a tunnel (several ISP uses 6rd...)
  • Unique Local IPv6 Unicast Addresses (site local)

Participating in IPv6 Network

The first approach is an option if your Funtoo Linux system happens to be on an IPv6 network, or you desire to set up an IPv6 network. In this case, the Funtoo Linux system simply needs to be configured to participate in this IPv6 network -- and can also participate in an IPv4 network simultaneously. If you will be configuring an IPv6-compatible router, then you will simply configure your Funtoo Linux system to participate in this network.

Local IPv6 over IPv4 Tunnel

Another approach for using IPv6 is to configure an IPv6 over IPv4 tunnel locally on your Funtoo Linux system, in cooperation with a tunnel provider. This will allow you to use an existing IPv4 network to connect a single Funtoo Linux system to IPv6. It is also possible to configure this system to serve as an IPv6 router.

Enabling IPv6 on Your Router

If you have a router that is capable of supporting IPv6, then it is possible to configure your router so that an IPv6 network is available, at which point you can simply configure your Funtoo Linux system to participate in it. Note that many popular home/office routers can be configured to use an IPv6 over IPv4 tunnel, which provides a convenient option for home networks or smaller organizations to participate in IPv6. Using this approach, your computer systems behind the router are simply configured to participate in an IPv6 network, and your router handles tunneling the IPv6 traffic back and forth between your tunnel provider. This is typically the most flexible option for exploring IPv6 as it allows you to have multiple computer systems in your home or office to participate in an IPv6 network while your router takes care of everything transparently.

Using Unique Local IPv6 Unicast Addresses

If you don't have public IPv6 connectivity or you don't wish to open an IPv6 tunnel over an IPv4 network, you can use a mechanism similar to IPv4 private addresses ranges. This mechanism consists of concatenating the prefix FC00::/7 with a globally unique identifier and a subnet identifier to form the upper 64 bits of the IPv6 address. Details of the mechanisms to forge a unique local IPv6 unicast address are documented in RFC 4193, however unique local IPv6 unicast addresses are made of the following components:

       | 7 bits |1|  40 bits   |  16 bits  |          64 bits           |
       +--------+-+------------+-----------+----------------------------+
       | Prefix |L| Global ID  | Subnet ID |        Interface ID        |
       +--------+-+------------+-----------+----------------------------+
  • Prefix (7 bits): always FC00::/7
  • L (1 bits): must be set to 1 (1 = prefix is locally assigned, 0 is undefined so far and must not be used)
  • Global ID: A random identifier (see RFC 4193 for details about the generation algorithm
  • Interface ID: Host interface ID as defined in RFC 3513

Note Note: Just like with private IPv4 addresses, an IPv6 router must not route a unique local IPv6 unicast address outside the organization local network.

ICMPv6

Some network administrators are pretty aggressive with ICMP filtering on their networks. Do not misunderstand us: ICMP is an integral part of the TCP/IP protocol stack and a necessary gear for its correct operation. ICMP messages are even more fundamental in IPv6 because some TCP/IP core mechanisms like have been replaced by ICMPv6 messages: ARP is no longer in use in an IPv6 world, instead a set of of ICMPv6 messages have been created to assume the same functionality (Neighbor Discovery Protocol or NDP). Also no fragmentation can be done in IPv6 and blocking ICMPv6 messages like Packet too big is not a good idea. In general: do not block any other ICMPv6 messages than echo request and echo reply .

Stateful vs stateless

There are several ways to assign IPv6 addresses on a network :

  • Stateful: a DHCPv6 server is responsible of leasing and following all assigned IPv6 addresses. It works the same way of the well known traditional DHCP with some minor variations but the idea beneath is exactly the same.
  • Stateless: Nothing leases or tracks assigned IPv6 addresses on the network. Instead, machines use either an IPv6 address manually entered by the network administrator either a combo of Router Advertisement messages with a magic calculation of their network adapter's MAC address (EUI-64).

Requirements

IPv6 requires CONFIG_IPV6 to be enabled in your kernel (either compiled in or as a module). If compiled as a module (e.g. if your kernel was compiled by genkernel), ensure the module is loaded.

# lsmod | grep ipv6

If this returns nothing, load the module with:

# modprobe ipv6

Commands

ping6
IPv6 ping command
route -6
show IPv6 routes
ip -6 neigh show
show all IPv6 neighbors on the local LAN

Configuration

Participating in an Existing IPv6 Network

If your local network already supports IPv6, then you can simply configure Funtoo Linux to participate in this IPv6 network. Here is a sample configuration that might be used to configure an ethernet interface (netif.eth0) to participate in both an IPv4 and IPv6 network:

template="interface"
ipaddr="10.0.1.200/24 2001:470:d:c2c:218:51ff:feea:ee21/64"
gateway="10.0.1.1"
nameservers="10.0.1.1 2001:470:20::2"
domain="funtoo.org"
multicast="yes"
routes="2000::/3 via fe80::daa2:5eff:fe7a:83de dev eth0"

Above, we use the interface template, and specify both an IPv4 and IPv6 address (with network mask) for ipaddr. In addition, an IPv4 and IPv6 nameserver is specified. For routing, we use the gateway command to specify an IPv4 gateway, while we use the routes command to specify a route to our router, which in this case has address fe80::daa2:5eff:fe7a:83de and is reachable on device eth0.

Note that we specify a route for "2000::/3" rather than "::/0" or "default", and this is a bit unusual. This is to work around a bug in many Linux kernels that prevents the default route from being handled properly. "2000::/3" maps to all routable IP addresses and has the benefit of being compatible with all Linux kernels.

Many Addresses and Stateless Autoconfiguration

Also note that if we did not specify an IPv6 address in the ipaddr variable, then eth0 would still get at least one IPv6 address anyway. First, it would get a link-local address, starting in fe80::/16, and it would also automatically use stateless autoconfiguration to grab an unused IPv6 address from the range used by your IPv6 router. This works similarly to the way a DHCP client works with IPv4, but is built-in to the IPv6 protocol and does not require a DHCP server to function. It works because with IPv6, routers send out ICMP packets to advertise themselves to systems on your network, and your Funtoo Linux system can use this information to automatically grab an unused address. It is important to understand this behavior because it means that by default, your Funtoo Linux system will grab a globally-routable ("public") IPv6 address from your router with no steps necessary on your part and thus may be accessible from the Internet if no firewall is in place. However, in most cases the default IPv6 route must be specified in the routes variable for IPv6 to function properly, so this auto-configuration isn't completely automatic at this time.

Local IPv6 over IPv4 Tunnelling

Tunnelling is the process of encapsulating IPv6 packets within an IPv4 packet so that it can be transmitted over an IPv4 network. This process happens at a local tunnel entry point, which can be a Linux machine or a router, such as an Apple AirPort. The packet then traverses the IPv4 network, until reaches the tunnel endpoint, which de-encapsulates the packet and places it on an IPv6 network. There are several different types of IPv6 tunnels. There are also several IPv6 tunnel providers that offer free tunnelling services, making it convenient to start using IPv6, even on your home network.

Note that if you want configure an IPv6 over IPv4 tunnel on your router, such as an Apple AirPort, then you will simply need to sign up with one of the tunnel providers and use their instructions to configure your router. At this point, your router will be IPv6 enabled and you can then configure your Funtoo Linux system to participate in an existing IPv6 network using the instructions in the previous section. If this is not an option for you, then it is also possible to set up the IPv6 over IPv4 tunnel directly on your Funtoo Linux system. This means that only your Funtoo Linux system will be able to participate in IPv6, at least to start (later, you could configure your Funtoo Linux system to route IPv6 for other machines on your network) Follow the instructions in this section to set up local tunneling on your Funtoo Linux system.

Tunnel providers

freenet6
Supports anonymous tunnels and works behind NAT. You can connect to with your login or as anonymous from anywhere. This can be configured under Funtoo Linux by emerging the net-misc/gogoc ebuild.
Hurricane Electric
Configured 6in4 tunnel, with support for dynamic IPv4 addresses, and Apple AirPorts can be configured to use this tunnel - see this link. Also see ipv6.he.net FAQ You can setup this tunnel with ifconfig and iproute2, or configure your router to be the tunnel entry point -- the point at which IPv6 traffic is encapsulated/de-encapsulated.
Teredo/Miredo
RFC4380 mandated transition mechanism. Works behind NAT. Assigns one "/128" per host.

Getting Started with gogoc

Freenet6 is a free IPv6 access service provided by gogo6 via the TSP tunnelling protocol. gogoc supports any TSP tunnel; perhaps one is provided by your ISP. We will focus on an anonymous tunnel via freenet6.

You need ipv6 to be enabled in your kernel as well as the TUN module.

You can quickly get started by emerging net-misc/gogoc, adding gogoc to your startup scripts and starting it. net-misc/gogoc is currently keyworded unstable (on some architectures, see gentoo bug #362549). If you are running stable Funtoo, you may want to put an entry into your package.keywords/package.accept_keywords file.

# emerge gogoc
# bzcat /usr/share/doc/gogoc-*/gogoc.conf.sample.bz2 >/etc/gogoc/gogoc.conf
# rc-update add gogoc default
# /etc/init.d/gogoc start

Note Note: By default, gogoc will use an anonymous tunnel. If you wish to authenticate yourself, read and edit /etc/gogoc/gogoc.conf.

Getting started with Teredo

While this mechanism is officially called Teredo, the implementation of the Teredo service we will be using is called Miredo. Note Note: net-misc/miredo is currently keyworded unstable. If you are running stable Funtoo, you may want to put an entry into your package.keywords/package.accept_keywords file.}}

Emerge net-misc/miredo and start it up (you can add it to your default runlevel if you wish):

# emerge net-misc/miredo
# /etc/init.d/miredo start

Note Note: Miredo requires CONFIG_TUN enabled in your kernel. If it is compiled as a module, ensure the tun module is loaded.

If all goes well, you can check the assignment of an IPv6 address using /sbin/ip, for example:

# /sbin/ip addr show dev teredo
4: teredo: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc pfifo_fast state UNKNOWN qlen 500
    link/none 
    inet6 2001:0:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/32 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::ffff:ffff:ffff/64 scope link 
       valid_lft forever preferred_lft forever

Tunnelling 6to4

6to4 is an Internet transition mechanism for migrating from IPv4 to IPv6, a system that allows IPv6 packets to be transmitted over an IPv4 network (generally the IPv4 Internet) without the need to configure explicit tunnels. When using 6to4 your IPv6 golablly addressable IP is generated from you IPv4 IP address.

The anycast address of 192.88.99.1 has been allocated for the purpose of sending packets to a 6to4 relay router. Note that when converted to a 6to4 IPv6 address with the subnet and hosts fields set to zero this IPv4 address (192.88.99.1) becomes the IPv6 address 2002:c058:6301::.

To use the funtoo network template method, write the config file for the interface /etc/conf.d/netif.6to4 (which will also handle the converting of your IPv4 address to your IPv6 address). Make sure you change "WAN" to your correct internet facing interface.

template=ipv6-tunnel
WAN="eth0"
MTU="1280" 
ipv4=`ifconfig $WAN | sed -ne 's/[[:space:]]*inet addr:\([0-9.]*\).*/\1/p'`
ipv6=`printf "2002:%02x%02x:%02x%02x::1" \`echo $ipv4 | tr "." " "\``
remote=192.88.99.1
local="$ipv4/24"
ipaddr="$ipv6/48"
routes="2000::/3 via 2002:c058:6301:: dev $WAN"

Then create the netif.6to4 symlink and add it to the default runlevel

# ln -s /etc/init.d/netif.tmpl /etc/init.d/netif.6to4
# rc-update add netif.6to4 default
# /etc/init.d/netif.6to4 start

You should now be capable of connecting via IPv6:

# ping6 ipv6.google.com

To allow this host to be a router, a modified template is required:

#!/bin/sh

netif_pre_up() {
        require local remote
        try ip tunnel add $interface mode sit remote $remote local $local ttl 255
        try ip addr add $ipaddr dev $interface
        try ip addr add $ipaddr4 dev $interface
}

netif_post_up() {
        try ip route add ::/0 dev $interface
}

netif_pre_down() {
        ip route del ::/0 dev $interface
}

netif_post_down() {
        ip tunnel del $interface
}

Then add the following line to /etc/conf.d/netif.6to4:

ipaddr4="$ipv4/24"

After restarting the 6to4 interface radvd can be started:

# /etc/init.d/netif.6to4 restart
# /etc/init.d/radvd start

Optimization

Prefer IPv4 over IPv6

Generally if your IPv6 connection is through a tunnel, it will be slower than an IPv4 connection. For this reason, if you are using an IPv6 tunnel, it can be best to configure your systems to prefer IPv4 if an IPv4 version of the site is available, and use IPv6 only when necessary. This way, you will avoid unnecessary encapsulation and de-encapsulation of IPv4 traffic. Here's how to do this for a number of operating systems:

Linux

Linux will prefer IPv6 if IPv6 support is enabled in the kernel. To prefer IPv4, edit /etc/gai.conf and add this line:

precedence ::ffff:0:0/96 100

Windows 7, Server 2008, Vista

These operating systems prefer IPv6 by default. See this link. To prefer IPv4, use the following steps:

  1. Start regedit.
  2. Navigate to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\TCPIP6\Parameters.
  3. Create a new DWORD named DisabledComponents. Edit this new DWORD and set it to HEX value of 20 or a DECIMAL value of 32.
  4. Restart your computer.

ISPs who currently have IPv6 enabled for residential customers

  • Canada:
    • Videotron: Videotron has a beta-program for residential customers who want to test IPv6 (no official technical support, it is possible they don't have enabled it in your area so check first before investing in new hardware). Although at date of writing, a large part of their networks are IPv6, you must go through a 6rd tunnel because they still need to upgrade some of their equipments and your router must support the 6rd protocol (this requirement is documented). Videotron sells you a D-Link DIR-825 with a modified firmware however this model has a weird gotcha: it does not support IPv6 firewalling. This is not a Videotron specific issue (even the genuine firmwares coming from the manufacturer has no support for IPv6 firewalling as of June 2011). A good alternative to recommend is the CISCO/LinkSYS E4200, more expensive (MSRP ~$180 US/CDN) but has IPv6 firewalling support. Once the E4200 firmware has been upgraded go in Setup/IPv6 Setup disable "IPv6 - Automatic" (you should then see an IPv6 address in the DUID field) and leave "automatic" for the 6rd configuration. You should be in business and see all of the hosts on your network with an IPv6 stack enabled being assigned a public IPv6 address starting with 2607:f048.
    • Teksavvy : TekSavvy has a IPv6 beta-program for residential customers who use their DSL service (no statement found for cable connections). Just ask them to enable IPv6 to your subscription and it should be available within the next 24 hours. Their IPv6 connectivity is native so you don't need to setup a tunnel.
    • Shaw (?)
    • Cogeco cable (?)
    • Telus (?)
    • Bell : Bell appears to have an official IPv6 support especially for its business subscribers (See http://ipv6.bell.ca) via a toolkit and various web pages on the subject.
  • France
    • Free
    • Nerim
    • the French Data Network (FDN)
  • United States:
    • Comcast (limited pilot in some areas only)

Home routers compatible with IPv6

A few residential routers have support for IPv6 at date of writing and many more home networking devices will have robust IPv6 support in a more or less near futures. The following does not pretend to be exhaustive:

  • D-Link DIR-825 rev. 1B (June 2011): Has IPv6 support out of the box, however for somewhat reason the router has no support for IPv6 firewalling even with teh 2.05N revision of the firmware. Consequence for you is you have to deploy an IPv6 firewall on each of hosts concerned with a public IPv6 connectivity. The canadian ISP Videotron is selling a DIR-825 with a customized firmware as unfortunately, like with the genuine manufacturer firmware, no IPv6 firewalling possible :( .
  • CISCO/LinkSys E4200 (June 2011): Advertised as being IPv6 compatible with a firmware update (available as of June 14th 2011 -> check for the version tagged 1.0.02 build 13 or later on the manufacturer website). The device supports native IPv6 and IPv6 through a 6rd tunnel (no support for any other tunneling protocol).

Resources

with Apple airport extreme, etc:

Nice Overview over IPv6