Moving to IPv6 web hosting

I decided to move this blog to an IPv6 web server because, well because I thought I ought to. We’re in the middle of the dual stacking project at Gconnect and the idea of using a new 30:30 server to isolate our blogs and web site, combined with IPv6 seemed nice! So whats the process??

Step 1: Create the 30:30 server

Thats easy! I selected a FreeBSD 9.1 base server with a security upgrade.

Step 2: add IPv6 to the FreeBSD server

Add to rc.conf the IPv6 details provided by Gconnect as follows (obviously yours will be different):

ifconfig_bce1_ipv6="inet6 2a01:570:1:405::211 prefixlen 64"
ipv6_defaultrouter="2a01:570:1:405::1"
ipv6_prefer="YES"

Now reboot the server to make it all come alive. If you want to add the IPv6 capability without reboot, then you can just manually add the info like this:

ifconfig bce1 inet6 2A01:570:1:31::19 prefixlen 64
route add -inet6 default 2A01:570:1:31::1

If you like you can put some IPv6 resolvers into the /etc/resolv.conf file and I also added some extra config to the /etc/hosts file as shown:

ee /etc/resolv.conf
--/add/--
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
--/--

ee /etc/hosts
--/add/--
2A01:570:1:405::211     gcweb1.gconnect.net gcweb1
--/--

You probably want to test this out now with a ping6

# ping6 ipv6.google.com
PING6(56=40+8+8 bytes) 2a01:570:1:405::211 --> 2a00:1450:400b:c02::6a
16 bytes from 2a00:1450:400b:c02::6a, icmp_seq=0 hlim=57 time=17.761 ms
16 bytes from 2a00:1450:400b:c02::6a, icmp_seq=1 hlim=57 time=18.055 ms

Step 3 Configure Apache

I’m assuming that you have installed Apache, PHP, MySQL and anything else you may need. I also assume it works with IPv4! If the previous steps were all successful you can see if apache is listening on IPv6 with sockstat -6

USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
www      httpd      54448 3  tcp6   *:80                  *:*
www      httpd      54447 3  tcp6   *:80                  *:*
www      httpd      54446 3  tcp6   *:80                  *:*
www      httpd      54412 3  tcp6   *:80                  *:*
www      httpd      54411 3  tcp6   *:80                  *:*
www      httpd      54410 3  tcp6   *:80                  *:*
www      httpd      54409 3  tcp6   *:80                  *:*
www      httpd      54408 3  tcp6   *:80                  *:*
root     httpd      54407 3  tcp6   *:80                  *:*
root     sshd       1069  3  tcp6   *:22                  *:*
root     syslogd    827   6  udp6   *:514                 *:*

This all looks good. I’m using virtual hosting so the only bit we need to edit is the /usr/local/etc/apache22/extra/httpd-vhosts.conf

NameVirtualHost 10.40.5.211
NameVirtualHost [2a01:570:1:405::211]

<VirtualHost 10.40.5.211>
ServerAdmin dan_at_gconnect.net
DocumentRoot /my/web/dir.
ServerName blog.danmassey.net
Directoryindex index.php index.html
ErrorLog /my/logs/error.log
CustomLog /my/logs/access combined
</VirtualHost>

<VirtualHost [2a01:570:1:405::211]>
ServerAdmin dan_at_gconnect.net
DocumentRoot /my/web/dir
ServerName blog.danmassey.net
ServerAlias newblog.danmassey.net
Directoryindex index.php index.html
ErrorLog /my/logs/error.log
CustomLog /my/logs/access combined
</VirtualHost>

Now just restart apache and you are away! Check it’s working by browsing to the site with IPv6 enabled client of your choice and then check the logs. You should see the IPv6 addresses in the log (here is my test):

2a01:570:1:31:d1db:d1cd:ffec:1f7d - - [15/Feb/2013:17:59:10 +0000] "GET / HTTP/1.1" 200 63173 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"

All good!

This entry was posted in Apache, FreeBSD Administration, IPv6. Bookmark the permalink.

Leave a Reply