Configuring An IPv6 Router And Client
Updated: 07/15/2005
General Information
This is part 1 of our upcoming series on IPv6. In this article we will explain how to setup and configure a FreeBSD router and client for IPv6. In upcoming articles you will learn how to configure and setup Windows Clients as well as OpenBSD routers and clients.What is IPv6?
By now, you've probably heard of the next generation Internet Protocol, IPv6. While it provides many improvements and new capabilities, the driving force behind its adoption is likely to be the much larger (and more flexible) address space that it defines. Continuing growth in the population of IP enabled devices has already put severe stress on address allocation and the routing infrastructure. The roll out of new enabling technologies, such as 3G wireless and broadband to the home, will predictably create a new wave of demand. Now the scope of this article is just going to cover how to setup IPv6 on various BSD platforms. This is going to be a very basic how-to on getting it setup and properly working.IPv6 Background Information
There are different types of IPv6 addresses: Unicast, Anycast and Multicast.Note: The IPv4 broadcast address (usually xxx.xxx.xxx.255) is expressed by multicast addresses in IPv6.
Reserved IPv6 addresses:
| ipv6-address | prefixlength(bits) | Description Notes |
| :: | 128 bits | Unspecified cf. 0.0.0.0 in IPv4 address |
| ::1 | 128 bits | Loopback address cf. 127.0.0.1 in IPv4 |
| ::00:xx:xx:xx:xx | 96 bits | Embedded IPv4 the lower 32 bits are the address IPv4 address. Also called "IPv4 compatible IPv6 address." |
| ::ff:xx:xx:xx:xx | 96 bits | IPv4 mapped the lower 32 bits are the IPv6 address IPv4 address. For hosts which do not support IPv6. |
| fe80:: - feb:: | 10 bits | Link-local cf. loopback address in IPv4 |
| fec0:: - fef:: | 10 bits | Site-local |
| ff:: | 8 bits | Multicast |
| 001 (base 2) | 3 bits | Global unicast. All global unicast addresses are assigned from this pool. The first 3 Bits are "001." |
Reading IPv6 Addresses
The canonical form is represented as: x:x:x:x:x:x:x:x, each "x" being a 16 Bit hex value. For example, FEBC:A574:382B:23C1:AA49:4592:4EFE:9982|
# ifconfig rl0: flags=8943 mtu 1500?inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255 inet6 fe80::200:21ff:fe03:8e1%rl0 prefixlen 64 scopeid 0x1 ether 00:00:21:03:08:e1 media: Ethernet autoselect (100baseTX ) status: active |
Picking Your Broker
Ok so now this is where things get fun. First of all, let's talk for a second about your choices of tunnel brokers. You're going to need one of these to get your IPv6 connection going.Configuration
Know Your Network
We're going to make a basic 2 computer network here: Your server and your client.| Server IPv4 address: | 111.111.111.111 |
| Server IPv6 address: | 2222:222:2222::222/127 |
| Client IPv4 address: | 333.333.333.333 |
| Client IPv6 address: | 4444:444:4444:444::444/127 |
| Assigned /64: | 5555:555:5555:555::/64 |
Configuring the Gateway on FreeBSD
Now let's start with the fun. Let's go and edit our/etc/rc.conf so our system knows about our new toy.|
#Your Gateway's Hostname Here hostname="gateway.yourdomain.com" #The Network Cards in your box network_interfaces="xl0 xl1 lo0" ##Loopback Interface ipv6_ifconfig_lo0="::1 prefixlen 128" ##External Interface ipv6_ifconfig_xl0="4444:444:4444:444::444 prefixlen 128" ipv6_prefix_xl0="5555:555:5555:555::" ##Internal Interface ipv6_ifconfig_xl1="5555:555:5555:555::1 prefixlen 64" #Extra Stuff ipv6_enable="YES" ipv6_network_interface="xl0 xl1" ipv6_default_router="2222:222:2222::222" rtadvd_enable="YES" rtadvd_interfaces="xl1" ipv6_gateway_enable="YES" ipfilter_rules="/etc/ipf.rules" ipv6_ipfilter_rules="/etc/ipf6.rules" |
/etc/rc.local and add something like this:|
echo -n " Establishing HE.NET Tunnel " /sbin/ifconfig gif0 create /sbin/ifconfig gif0 tunnel 333.333.333.333 111.111.111.111 /sbin/ifconfig gif0 inet6 4444:444:4444:444::444 2222:222:2222::222 prefixlen 128 /sbin/route -n add -inet6 default 2222:222:2222::222 /sbin/ifconfig gif0 up |
/etc/sysctl.conf and add these lines in there:|
net.inet6.ip6.accept_rtadv=0 net.inet6.ip6.forwarding=1 |
/etc/rtadvd.conf and file it should contain something like the following:|
default: :raflags#0:rltime#3600: :pinfoflags#64:vltime#360000:pltime#360000:mtu#1500: ether: :mtu#1280:tc=default: # interfaces. xl1: :addrs#1: :addr="5555:555:5555:555::":prefixlen#64:tc=ether: |
/etc/ipf.rules you should have a pass our in and out rule for each interface to allow the IPv6 packets.|
pass out quick on xl0 proto ipv6 all pass in quick on xl0 proto ipv6 all |
/etc/ipf6.rules
|
pass out quick all pass in quick all |
/etc/hosts file. Here we have something like this:|
::1 localhost 127.0.0.1 localhost.my.domain localhost 5555:555:5555:555::1 server.yourdomain.com server 333.333.333.333 server.yourdomain.com server 5555:555:5555:555::aaaa client.yourdomain.com client 10.0.0.4 client.yourdomain.com client |
|
# ping6 www.6bone.net PING6(56=40+8+8 bytes) 4444:444:4444:444::444 --> 3ffe:b00:c18:1::10 16 bytes from 3ffe:b00:c18:1::10, icmp_seq=0 hlim=61 time=175.393 ms 16 bytes from 3ffe:b00:c18:1::10, icmp_seq=1 hlim=61 time=179.547 ms 16 bytes from 3ffe:b00:c18:1::10, icmp_seq=2 hlim=61 time=204.748 ms --- 6bone.net ping6 statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max/std-dev = 175.393/186.563/204.748/12.970 ms |
Configuring A FreeBSD IPv6 Client
Now the hard part is done you have a routing IPv6 stack. So we just need to tell our clients there is an address available and to use it. First, we need to tell our client to accept RA broadcasts. Go and edit your/etc/sysctl.conf file and add in the following:|
net.inet6.ip6.accept_rtadv=1 net.inet6.ip6.forwarding=0 |
| # | rtsol -D xl0 |
Note: Replace xl0 with whatever your NIC is.
|
checking if xl0 is ready... xl0 is ready set timer for xl0 to 0:184944 New timer is 0:00184701 timer expiration on xl0, state = 1 send RS on xl0, whose state is 2 set timer for xl0 to 4:0 New timer is 4:00001235 received RA from XXXX::XXX:XXXXXXXX:XXXX on xl0, state is 2 stop timer for xl0 there is no timer |
ping6 www.6bone.net from the client. Now I would suggest you add the rtsol command to your /etc/rc.local to avoid future headache's. Some other configurations you will need to do are (these are not required but nice to have):|
ifconfig_lo0="inet 127.0.0.1" ipv6_ifconfig_lo0="::1 prefixlen 128" ipv6_ifconfig_xl0="YOUR GIVEN IPV6 ADDRESS FROM THE GATEWAY prefixlen 64" ipv6_prefix_xl0="5555:555:5555:555::" ipv6_default_router="5555:555:5555:555::1" ipv6_enable="YES" ipv6_network_interface="xl0" |
References
OnlampAuthor: Leigh Renfrow
soup4you2 at mac dot com