Alright, so as we all know IPv4 is reaching the point of exhaustion and its time to start getting ready for IPv6. This can be very important for those of us who host web servers as many hosting providers will also be switching to assigning IPv6 addresses or NAT based Private IP’s in the Class A space 10.0.0.0/8 for IPv4 or fc00::/7 for IPv6 (Unique Local Address “ULA”).
With that in mind how are you going to host your website on IPv6 address space? There are many web servers available as free Open Source software such as nginx, apache (httpd), and lighthttpd. For the context of this article we will focus on apache, and assume that you already have IPv6 connectivity and an understanding of virtual hosts.
Here are a few things that you are going to need to get started:
As the transition to IPv6 progresses you should see your hosting provider assigning IPv6 addresses. At this time many hosting companies have not yet caught up to this as implementing IPv6 networking and connectivity can be extremely time consuming and expensive. Currently Verio, Linode, and Liquid Web all provide web hosting with IPv6 connectivity.
Once you have confirmed that the network appliance your server is connected to has IPv6 capabilities, and your provider has assigned you an IPv6 address you can get started configuring your network interfaces. There are many ways this can be done but we will only cover binding an IPv6 address to an interface already serving traffic over IPv4.
First things first.. enable IPv6 networking by adding the following line to /etc/sysconfig/network on a redhat based Linux distribution.
NETWORKING_IPV6=yes
This is one of the files your init scripts consults with to identify what networking services to start. Now we can move on to configuring the interface. Mentioned previously we will be configuring a single interface to serve both IPv4 and IPv6 traffic. In this example we will be binding these addresses to eth0.
Here are the parameters we must edit:
Example:
IPV6INIT=yes IPV6ADDR=2600:3c01::f03c:91ff:fe93:eb17 IPV6_DEFAULTGW=fe80::1
At this point you should be ready to restart networking and test connectivity. This will differ slightly from some of the tools we use for testing IPv4. For example if you wanted to run a simple ping command you would use ping6 or a third party site such as SubnetOnline.
/etc/init.d/networking restart
PING 2600:3c01::f03c:91ff:fe93:eb17(2600:3c01::f03c:91ff:fe93:eb17) 32 data bytes 40 bytes from 2600:3c01::f03c:91ff:fe93:eb17: icmp_seq=0 ttl=245 time=176 ms 40 bytes from 2600:3c01::f03c:91ff:fe93:eb17: icmp_seq=1 ttl=245 time=144 ms 40 bytes from 2600:3c01::f03c:91ff:fe93:eb17: icmp_seq=2 ttl=245 time=144 ms 40 bytes from 2600:3c01::f03c:91ff:fe93:eb17: icmp_seq=3 ttl=245 time=144 ms --- 2600:3c01::f03c:91ff:fe93:eb17 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3010ms rtt min/avg/max/mdev = 144.641/152.757/176.961/13.982 ms, pipe 2
If a ping from your workstation does not work do not be alarmed.. your local network may not have IPv6 connectivity. If you should encounter any issues up to this point you should consult with your hosting provider to ensure your interfaces are configured properly and you have the correct configuration.
Now that we have networking configured we can move on to configuring our virtual hosts. Virtual hosts are pretty easy to configure, however there are multiple steps. First and foremost you must configure apache to listen on your IPv6 interface. This is pretty easy to do however there is an important syntax change that you need to be aware of..
When configuring apache to listen on an IPv4 interface using port 80 you would typically use the following statement in httpd.conf:
Listen 127.0.0.1:80This changes very slightly but the IPv6 address requires brackets around it like in this example:
Listen [2600:3c01::f03c:91ff:fe93:eb17]:80
Below is an example virtual host configuration. This is pretty standard and does not provide any cache control or any additional features. Here is a break down on the configuration:
mkdir /etc/httpd/vhost.d echo "Include vhost.d/*.conf" >> /etc/httpd/conf/httpd.conf
This would provide you with the ability to create a file such as “/etc/httpd/vhost.d/mydomain.conf” where you would store your virtual host configuration. Doing this keeps httpd.conf clean, and also makes things a bit easier to manage.
ServerName www.yoursite.com
ServerAlias www.yoursite.com yoursite.com
UseCanonicalName Off
DocumentRoot /home/yoursite/public_html
ErrorLog /var/log/httpd/yoursite-error_log
CustomLog /var/log/httpd/yoursite-access_log combined
Options -Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from allNow that your virtual hosts are configured its time to restart apache and start hosting your website. I hope whoever reads this finds it helpful. If you have any questions please feel free to comment below.
