Aug 132011
 

Welcome to part one of my multipart series on IPv6. In this post I’ll cover how to configure a FreeBSD host to use a static IPv6 address. The host used runs FreeBSD 8.2, but it should be applicable to just about any version of FreeBSD with IPv6 support.

I have a FreeBSD host collocated with a company that provides native IPv6. Each host is assigned a /64 netblock and the first address is the default gateway. I elected to take the second IP in the subnet for the host, mostly because it’s easy to remember and this host functions as my primary name and web server.

To configure a FreeBSD host with a static IPv6 address, all you have to do is add the following lines to /etc/rc.conf:

[cc lang=”bash”]
$ cat /etc/rc.conf | grep ipv6
ipv6_enable=”YES”
ipv6_ifconfig_em0=”2001:0DB8:1000:8b00::2 prefixlen 64″
ipv6_defaultrouter=”2001:0DB8:1000:8b00::1″
[/cc]

You will of course want to substitute your own IPv6 address and gateway. To actually enable the IPv6 address without rebooting, run this command:

[cc lang=”bash”]
$ /etc/rc.d/network_ipv6 start
[/cc]

Here’s what the interface looks like:

[cc lang=”bash”]
$ ifconfig em0
em0: flags=8843 metric 0 mtu 1500
options=209b
ether 00:16:3e:1c:57:46
inet6 fe80::216:3eff:fe1c:5746%em0 prefixlen 64 scopeid 0x1
inet6 2001:0DB8:1000:8b00::2 prefixlen 64
inet 203.0.113.238 netmask 0xfffffffc broadcast 203.0.113.239
nd6 options=3 media: Ethernet autoselect (1000baseT )
status: active
[/cc]

And here’s the IPv6 routing table:

[cc lang=”bash”]
$ netstat -rn -f inet6
::/96                             ::1                           UGRS        lo0 =>
default                           2001:0DB8:1000:8b00::1        UGS         em0
::1                               ::1                           UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
2001:0DB8:1000:8b00::/64          link#1                        U           em0
2001:0DB8:1000:8b00::2            link#1                        UHS         lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%em0/64                     link#1                        U           em0
fe80::216:3eff:fe1c:5746%em0      link#1                        UHS         lo0
fe80::%lo0/64                     link#4                        U           lo0
fe80::1%lo0                       link#4                        UHS         lo0
ff01:1::/32                       fe80::216:3eff:fe1c:5746%em0  U           em0
ff01:4::/32                       ::1                           U           lo0
ff02::/16                         ::1                           UGRS        lo0
ff02::%em0/32                     fe80::216:3eff:fe1c:5746%em0  U           em0
ff02::%lo0/32                     ::1                           U           lo0
[/cc]

Note there are actually two IPv6 addresses on the interface. There’s the assigned and globally routable address, and the other is the link-local address – the one starting with fe80. The link-local address is used for neighbor and router solicitation and discovery purposes, among other uses. The link-local address is assigned automatically, and is based on the MAC address.

Sorry, the comment form is closed at this time.