IPv6: Difference between revisions

From BitFolk
Jump to navigation Jump to search
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Some notes about configuring '''IPv6''' at BitFolk.
Some notes about configuring '''IPv6''' at BitFolk.
==Things changed in October 2024==
{{warning|Starting in October 2024 [[New_/48_assignments,_October_2024|BitFolk began assigning customers IPv6 netblocks from a different range]], and all existing customer VMs were also assigned blocks from that new range. This article will only discuss the current, up-to-date configuration.}}


==Your IPv6 assignment==
==Your IPv6 assignment==
By default customers are assigned a /64 of IPv6 space that starts with '''2001:ba8:1f1:'''. The next four hexadecimal digits will identify your /64. For example:
By default customers are assigned a /48 of IPv6 space that starts with '''2a0a:1100:1'''. The next three hexadecimal digits will identify your /48. For example:


<syntaxhighlight highlight="3">
<syntaxhighlight highlight="3" lang="text">
$ ip -6 addr show dev eth0
$ ip -6 address show dev enX0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
2: enX0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
     inet6 2001:ba8:1f1:f004:a800:ff:fe6a:380c/64 scope global  
     inet6 2a0a:1100:1018::/128 scope global  
       valid_lft forever preferred_lft forever
       valid_lft forever preferred_lft forever
</syntaxhighlight>
</syntaxhighlight>


This would indicate that '''2001:ba8:1f1:f004::/64''' is this customer's assignment.
This would indicate that '''2a0a:1100:1018::/48''' is this customer's assignment - the /128 is a single IP address from that assignment.


In this case the address '''2001:ba8:1f1:f004:a800:ff:fe6a:380c''' has been dynamically assigned, but all addresses between '''2001:ba8:1f1:f004::2''' and '''2001:ba8:1f1:f004:ffff:ffff:ffff:ffff''' are available to the customer for assignment (2<sup>64</sup>-2 addresses). '''2001:ba8:1f1:f004::1''' is used for the IPv6 default gateway.
In this case the very first (all zeroes) address '''2a0a:1100:1018::''' has been configured, but all addresses between '''2a0a:1100:1018:0000:0000:0000:0000:0000''' and '''2a0a:1100:1018:ffff:ffff:ffff:ffff:ffff''' are available to the customer for assignment (2<sup>80</sup>-1 addresses).
 
As with IPv4, your IPv6 assignment is [https://panel.bitfolk.com/dns/#toc-ipv6 listed in the Panel].


==Static IPv6 configuration==
==Static IPv6 configuration==
You might wish to disable autoconfiguration and statically assign your IPv6 addresses. The typical way to do this is with the files in '''/proc/sys/''' (or equivalent settings using '''sysctl'''). The following files in '''/proc/sys/''' are relevant:
Dynamic IPv6 address allocation is not used at BitFolk.


<syntaxhighlight>
==Configuring additional IPv6 addresses==
/proc/sys/net/ipv6/conf/default/accept_ra
===ifupdown (Debian)===
/proc/sys/net/ipv6/conf/all/accept_ra
'''ifupdown''' is currently the default network configuration framework on Debian. Other popular options are '''netplan''' or '''systemd-networkd''' directly. It is also possible to use '''NetworkManager''', though that is usually only used on Debian desktop systems.
/proc/sys/net/ipv6/conf/eth0/accept_ra
/proc/sys/net/ipv6/conf/default/autoconf
/proc/sys/net/ipv6/conf/all/autoconf
/proc/sys/net/ipv6/conf/eth0/autoconf
</syntaxhighlight>


If you echo "0" to all of the above files then IPv6 autoconfiguration will be disabled.
'''ifupdown''' is configured with the '''/etc/network/interfaces''' file (or in files included from that file). Your starting configuration will look something like this, covering both IPv4 and IPv6:


The best way to do this will vary by distribution.
<syntaxhighlight lang="text">
auto enX0
iface enX0 inet static
    address 85.119.82.121/21
    gateway 85.119.80.1


===CentOS===
iface enX0 inet6 static
Enable IPv6 in '''/etc/sysconfig/network''':
    address 2a0a:1100:1018::/128
 
    gateway fe80::1
<syntaxhighlight>
    # This blackhole route is REQUIRED by BitFolk policy in order to prevent
NETWORKING_IPV6=yes
    # traffic for unused addresses looping back out. It will not affect any
    # directly added IP address or route you have. Please do not remove it!
    #
    # If you do not like traffic to unknown adresses being silently dropped you
    # can change "blackhole" to "prohibit" which will result in your host
    # kernel sending back an ICMP Communication with Destination
    # Administratively Prohibited (type 1, code 1) message.
    #
    # Using firewall rules for the same purpose would also be acceptable.
    # ⬇️⬇️⬇️ Please do not remove
    post-up ip route add blackhole 2a0a:1100:1000::/48
    # ⬆️⬆️⬆️ Please do not remove
</syntaxhighlight>
</syntaxhighlight>


Configure IPv6 on the interface config file, e.g. '''/etc/sysconfig/network-scripts/ifcfg-eth0''':
To add another IPv6 address simply add another <tt>iface</tt> block lower down:


<syntaxhighlight>
<syntaxhighlight lang="text">
IPV6INIT=yes
iface enX0 inet6 static
IPV6_AUTOCONF=no
    address 2a0a:1100:1018::1/128
IPV6ADDR=2001:ba8:1f1:f004::2/64
IPV6_DEFAULTGW=2001:ba8:1f1:f004::1
</syntaxhighlight>
</syntaxhighlight>


Both of the above are in addition to what's already in those files. They're also case-sensitive, i.e. "yes" works but "YES" doesn't.
It will not require a <tt>gateway</tt> directive.


After doing this you would then need to reboot or issue '''service network restart'''. I'd recommend doing that from the xen shell console though!
===netplan (Ubuntu 18.04 onwards)===
Just add more IPv6 addresses to the <code>addresses:</code> list in the config file (e.g. '''/etc/netplan/01-netcfg.yaml'''):


===Debian/Ubuntu===
<syntaxhighlight lang="yaml">
You could put something like this in '''/etc/network/interfaces''':
network:
  version: 2
  ethernets:
    enX0:
      addresses:
        - "85.119.82.121/21"
        - "2a0a:1100:1018::/128"
        - "2a0a:1100:1018::1/128"
      routes:
        - to: default
          via: "85.119.80.1"
        - to: default
          via: "fe80::1"
        - to: "2a0a:1100:1018::/48"
          via: "::"
          type: blackhole
      nameservers:
        addresses:
          - "85.119.80.232"
          - "85.119.80.233"
          - "2001:ba8:1f1:f205::53"
          - "2001:ba8:1f1:f206::53"
</syntaxhighlight>
 
To update the config and then make it live:


<syntaxhighlight>
<syntaxhighlight lang="text">
iface eth0 inet6 static
$ sudo netplan try
    address 2001:ba8:1f1:f004::2
    netmask 64
    gateway 2001:ba8:1f1:f004::1
    post-up echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/default/autoconf
    post-up echo 0 > /proc/sys/net/ipv6/conf/all/autoconf
    post-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
</syntaxhighlight>
</syntaxhighlight>


'''$IFACE''' is replaced by the name of the interface by the network configuration scripts.
This will ask you for confirmation that everything is still working. If you don't provide it within a few seconds it will revert the change.


==Configuring additional IPv6 addresses==
===NetworkManager (CentOS and other Red Hat-like systems)===
===CentOS===
CentOS and other Red Hat-like systems use '''NetworkManager''' by default. This can be reconfigured live on the command line using '''nmcli'''.
In the interface config file, e.g. '''/etc/sysconfig/network-scripts/ifcfg-eth0''', add the following line:
 
<syntaxhighlight>
IPV6ADDR_SECONDARIES="2001:ba8:1f1:f004::1337"
</syntaxhighlight>


Additional secondaries are added as a space separated list:
To add an extra IPv6 address:


<syntaxhighlight>
<syntaxhighlight lang="text">
IPV6ADDR_SECONDARIES="2001:ba8:1f1:f004::1337 2001:ba8:1f1:f004::dead:beef"
# nmcli connection modify enX0 +ipv6.addresses 2a0a:1100:1018::1/128
</syntaxhighlight>
</syntaxhighlight>


===Debian/Ubuntu===
There isn't a nice way to do this yet like there is for IPv4 addresses, so you're forced to call the '''ip''' command from the '''post-up''' option. Example:


<syntaxhighlight>
===systemd-networkd===
iface eth0 inet6 static
Help?
    address 2001:ba8:1f1:f004::2
    netmask 64
    gateway 2001:ba8:1f1:f004::1
# Disable autoconf
    post-up echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/default/autoconf
    post-up echo 0 > /proc/sys/net/ipv6/conf/all/autoconf
    post-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
# Add another IPv6 address
    post-up ip -6 address add 2001:ba8:1f1:f004::1337/64 dev $IFACE
</syntaxhighlight>


===The default IPv6 source address===
===The default IPv6 source address===
The source address chosen for IPv6 packets is typically the last one added to the system. This may be undesirable if you are adding addresses that you wish to dedicate to certain services. You can force a particular IPv6 address to be used as source by marking all the other addresses as ''deprecated''. Deprecated addresses will still receive traffic and can still source traffic if they are specifically requested, but by default will not be used as a source address. You mark an IPv6 address as deprecated by setting its '''preferred_lft''' to '''0'''.
The source address chosen for IPv6 packets is typically the last one added to the system. This may be undesirable if you are adding addresses that you wish to dedicate to certain services. You can force a particular IPv6 address to be used as source by marking all the other addresses as ''deprecated''. Deprecated addresses will still receive traffic and can still source traffic if they are specifically requested, but by default will not be used as a source address. You mark an IPv6 address as deprecated by setting its <code>preferred_lft</code> to <code>0</code>.


====Deprecating existing addresses====
====Deprecating existing addresses====
Given the following IPv6 setup:
Given the following IPv6 setup:


<syntaxhighlight>
<syntaxhighlight lang="text">
$ ip -6 addr show dev eth0
$ ip -6 addr show dev enX0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
2: enX0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
     inet6 2001:db8:1f1:f1eb::2/64 scope global  
     inet6 2a0a:1100:1018::/128 scope global  
       valid_lft forever preferred_lft forever
       valid_lft forever preferred_lft forever
     inet6 2001:db8:1f1:f1eb::53/64 scope global  
     inet6 2a0a:1100:1018::1/128 scope global  
       valid_lft forever preferred_lft forever
       valid_lft forever preferred_lft forever
</syntaxhighlight>
</syntaxhighlight>


Here '''2001:db8:1f1:f1eb::53''' will most likely be used as a source address because it was added last. In order to force '''2001:db8:1f1:f1eb::2''' to be used, you can use '''ip address change''' to deprecate the other one:
Here '''2a0a:1100:1018::1''' will most likely be used as a source address because it was added last. In order to force '''2a0a:1100:1018::''' to be used, you can use <code>ip address change</code> to deprecate the other one:


<syntaxhighlight>
<syntaxhighlight lang="text">
# ip -6 addr change 2001:db8:1f1:f1eb::53/64 dev eth0 preferred_lft 0
# ip address change 2a0a:1100:1018::1 dev enX0 preferred_lft 0
# ip -6 addr show dev eth0
# ip address show dev enX0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
2: enX0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
     inet6 2001:db8:1f1:f1eb::53/64 scope global deprecated  
     inet6 2a0a:1100:1018::1/128 scope global deprecated  
       valid_lft forever preferred_lft forever
       valid_lft forever preferred_lft 0sec
     inet6 2001:db8:1f1:f1eb::2/64 scope global  
     inet6 2a0a:1100:1018::/128 scope global  
       valid_lft forever preferred_lft forever
       valid_lft forever preferred_lft forever
</syntaxhighlight>
</syntaxhighlight>
Line 131: Line 140:
To make the change permanent you'll need to set it in your network configuration.
To make the change permanent you'll need to set it in your network configuration.


====Debian/Ubuntu====
====Debian====
<syntaxhighlight>
<syntaxhighlight lang="text">
iface eth0 inet6 static
# This one is to be the one that is used for outbound traffic by default
# This one is to be the one that is used for outbound traffic by default
     address 2001:ba8:1f1:f004::2
iface enX0 inet6 static
    netmask 64
     address 2a0a:1100:1018::/128
     gateway 2001:ba8:1f1:f004::1
     gateway fe80::1
# Disable autoconf
    # skipped all the stuff about blackhole route in this example
    post-up echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
 
    post-up echo 0 > /proc/sys/net/ipv6/conf/all/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
    post-up echo 0 > /proc/sys/net/ipv6/conf/default/autoconf
    post-up echo 0 > /proc/sys/net/ipv6/conf/all/autoconf
    post-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf
# Perhaps you will only use this one for web serving
# Perhaps you will only use this one for web serving
     post-up ip -6 address add 2001:ba8:1f1:f004::80 dev $IFACE preferred_lft 0
iface enX0 inet6 static
# Add another IPv6 address. If it wasn't for the use of preferred_lft 0 this
     address 2a0a:1100:1018::80/128
# one would probably be the default source address
    preferred-lifetime 0
     post-up ip -6 address add 2001:ba8:1f1:f004::1337/64 dev $IFACE preferred_lft 0
 
# Add another IPv6 address. If it wasn't for the use of
# preferred-lifetime 0 this one would probably be the default source
# address as it was added last
iface enX0 inet6 static
     address 2a0a:1100:1018::bfbf/128
    preferred-lifetime 0
</syntaxhighlight>
</syntaxhighlight>
====netplan (Ubuntu 18.04 onwards)====
In '''netplan''' configuration you can set the <code>preferred_lft</code> on any address in the <code>addresses:</code> list:
<syntaxhighlight lang="text">
      addresses:
        - "85.119.82.121/21"
        - "2a0a:1100:1018::/128"
        - "2a0a:1100:1018::1/128":
            lifetime: 0
</syntaxhighlight>
====NetworkManager (CentOS and other Red Hat-like systems)====
We haven't been able to work out if '''NetworkManager''' can set the <code>preferred_lft</code> of individual addresses apart from autogenerated addresses. Please update if you know how.
It may be possible to use a hook script to run the equivalent <code>ip address change … preferred_lft 0</code> command.
In general, addresses defined with <code>nmcli connection modify enX0 ipv6.addresses …</code> are in ''decreasing'' order of priority, so the first one is the preferred source address.


==Firewalling==
==Firewalling==
Don't forget that you'll need to firewall your IPv6 just like you firewall your IPv4. The tool to do so is '''ip6tables'''.
Don't forget that you'll need to firewall your IPv6 just like you firewall your IPv4. The tool to do so is either '''nft''' (current) or '''ip6tables''' (deprecated).


===Neighbor Discovery===
===Neighbor Discovery===
IPv6 uses neighbor discovery to map IPv6 addresses to Ethernet (MAC) addresses. This replaces the functionality of ARP in IPv4, and as a result means you do need to allow some types of ICMPv6 traffic through if you want anything at all to work:
IPv6 uses neighbor discovery to map IPv6 addresses to Ethernet (MAC) addresses. This replaces the functionality of ARP in IPv4, and as a result means ''you do need to allow some types of ICMPv6 traffic through if you want anything at all to work'':
 
====nft====
Help?


<syntaxhighlight>
====ip6tables====
ip6tables --append INPUT -p ipv6-icmp --icmpv6-type neighbor-advertisement -j ACCEPT
<syntaxhighlight lang="text">
ip6tables --append INPUT -p ipv6-icmp --icmpv6-type neighbor-solicitation  -j ACCEPT
--append INPUT -p ipv6-icmp --icmpv6-type neighbor-advertisement -j ACCEPT
--append INPUT -p ipv6-icmp --icmpv6-type neighbor-solicitation  -j ACCEPT
</syntaxhighlight>
</syntaxhighlight>


Alternatively you may just want to allow everything on link-local addresses:
Alternatively you may just want to allow everything on link-local addresses:


<syntaxhighlight>
<syntaxhighlight lang="text">
ip6tables --append INPUT -s fe80::/10 -j ACCEPT
--append INPUT -s fe80::/10 -j ACCEPT
</syntaxhighlight>
 
===Router Advertisements===
If you wish to allow stateless address autoconfiguration from BitFolk to work then you need to allow the following in your IPv6 firewall:
 
<syntaxhighlight>
ip6tables --append INPUT  -p icmpv6 --icmpv6-type router-advertisement -j ACCEPT
ip6tables --append OUTPUT -p icmpv6 --icmpv6-type router-solicitation  -j ACCEPT
</syntaxhighlight>
</syntaxhighlight>


==Preferring IPv4 over IPv6==
==Preferring IPv4 over IPv6==
Sometimes a host has both IPv4 and IPv6 addresses. By default, Linux tends to prefer IPv6. If for some reason you wish to prefer IPv4 addresses then you can do so by adding:
Sometimes a remote host will have both IPv4 and IPv6 addresses. By default, Linux tends to prefer IPv6. If for some reason you wish to prefer IPv4 addresses then you can do so by adding:


<syntaxhighlight>
<syntaxhighlight lang="text">
precedence ::ffff:0:0/96 100
precedence ::ffff:0:0/96 100
</syntaxhighlight>
</syntaxhighlight>
Line 189: Line 212:
If you don't use IPv6 yet then it might be best to explicitly disable it.
If you don't use IPv6 yet then it might be best to explicitly disable it.


===Debian===
===Kernel level===
====lenny====
Arranging for <code>ipv6.disable=1</code> to be added to the kernel's command line should work on any Linux distribution from its next boot.
IPv6 is a module on lenny and earlier but you can't just unload it once it's been loaded. You need to ''blacklist'' it from being loaded:
 
===Debian/Ubuntu===
IPv6 can be disabled with a '''sysctl''', for example:
 
<syntaxhighlight lang="text">
# echo 'net.ipv6.conf.all.disable_ipv6=1' > /etc/sysctl.d/disableipv6.conf
</syntaxhighlight>
 
As IPv6 support is built into the kernel this will disable IPv6 from the next reboot.
 
===CentOS and other Red Hat-like systems===
Unknown if '''NetworkManager''' will obey the above sysctl. Let us know?
 
==Reverse DNS==
===Automated IPv6 reverse DNS (default)===
By default you have generic automatic reverse DNS for IPv6 that looks a bit like this:


<syntaxhighlight>
<syntaxhighlight lang="text">
# echo 'blacklist ipv6' >> /etc/modprobe.d/blacklist
$ dig +noall +answer -x 2a0a:1100:1018::
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa. 3600 IN PTR 2a0a-1100-1018-0-0-0-0-0.autov6rev.bitfolk.space.
dig +noall +answer -t aaaa 2a0a-1100-1018-0-0-0-0-0.autov6rev.bitfolk.space.
2a0a-1100-1018-0-0-0-0-0.autov6rev.bitfolk.space. 3600 IN AAAA 2a0a:1100:1018::
</syntaxhighlight>
</syntaxhighlight>


Note the append (>>) — this file has useful things in it already.
As you can see, it resolves correctly both ways.


You will need to reboot for this to take effect.
===Controlling your own IPv6 reverse DNS===
If instead you would like to take control of your IPv6 reverse DNS then BitFolk can delegate the reverse DNS for your zone to nameservers you specify. These can all be nameservers you control, or BitFolk can provide up to three of them (you just provide the primary: [[Secondary_DNS_service|see the page on secondary DNS for more information.]])


====squeeze or beyond====
The reverse zone for '''2a0a:1100:1018::/48''' would be called '''8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa'''. You can work this out using '''dig'''. For example:
IPv6 support is built into the kernel on squeeze and beyond. You can disable it with a '''sysctl''', for example:


<syntaxhighlight>
<syntaxhighlight lang="text">
# echo 'net.ipv6.conf.all.disable_ipv6=1' > /etc/sysctl.d/disableipv6.conf
$ dig +noall +question -x 2a0a:1100:1018::
;0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa. IN PTR
</syntaxhighlight>
</syntaxhighlight>


will disable IPv6 from the next reboot.
or '''sipcalc''':
 
<syntaxhighlight lang="text">
$ sipcalc -ar 2a0a:1100:1018::
-[ipv6 : 2a0a:1100:1018::] - 0


===Ubuntu===
[IPV6 INFO]
Lucid (10.04 LTS) and onwards are the same as Debian squeeze.
Expanded Address        - 2a0a:1100:1018:0000:0000:0000:0000:0000
Compressed address      - 2a0a:1100:1018::
Subnet prefix (masked)  - 2a0a:1100:1018:0:0:0:0:0/128
Address ID (masked)     - 0:0:0:0:0:0:0:0/128
Prefix address          - ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
Prefix length          - 128
Address type            - Aggregatable Global Unicast Addresses
Network range          - 2a0a:1100:1018:0000:0000:0000:0000:0000 -
                          2a0a:1100:1018:0000:0000:0000:0000:0000


==Reverse DNS==
[V4INV6]
By default you have no reverse DNS for IPv6. BitFolk will delegate the reverse DNS for your zone to nameservers you specify. These can all be nameservers you control, or BitFolk can provide up to three of them (you just provide the master).
Expanded v4inv6 address - 2a0a:1100:1018:0000:0000:0000:0.0.0.0
Compr. v4inv6 address  - 2a0a:1100:1018::0.0.0.0


The reverse zone for '''2001:ba8:1f1:f004::/64''' would be called '''4.0.0.f.1.f.1.0.8.a.b.0.1.0.0.2.ip6.arpa'''. You can work this out using '''dig'''. For example:
[IPV6 DNS]
Reverse DNS (ip6.arpa)  -
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa.


<syntaxhighlight>
-
$ dig +noall +question -x 2001:ba8:1f1:f004::1
;1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.0.0.f.1.f.1.0.8.a.b.0.1.0.0.2.ip6.arpa. 86371 IN PTR
</syntaxhighlight>
</syntaxhighlight>


The '''1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0''' part is the record you put in your zone and the '''4.0.0.f.1.f.1.0.8.a.b.0.1.0.0.2.ip6.arpa''' is the name of the zone itself. Here is what a typical BIND-format zone file might look like:


<syntaxhighlight>
The '''0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0''' part is the record you put in your zone and the '''8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa''' is the name of the zone itself. Here is what a typical BIND-format zone file might look like:
$ORIGIN 4.0.0.f.1.f.1.0.8.a.b.0.1.0.0.2.ip6.arpa.
 
<syntaxhighlight lang="text">
$ORIGIN 8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa.
$TTL 10800      ; 3 hours
$TTL 10800      ; 3 hours
@                      IN SOA a.ns.example.com. hostmaster@example.com. (
@                      IN SOA a.ns.example.com. hostmaster@example.com. (
                             2010122701   ; serial
                             2024103101   ; serial
                                   1800  ; refresh (30 mins)
                                   1800  ; refresh (30 mins)
                                     900  ; retry (15 mins)
                                     900  ; retry (15 mins)
Line 239: Line 295:
                                 NS c.ns.example.com.
                                 NS c.ns.example.com.


; Example reverse DNS for 2001:ba8:1f1:f004::1
; Example reverse DNS for 2a0a:1100:1018::
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR ruminant.ipv6.bitfolk.com.
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR ruminant.example.com.
; Example reverse DNS for 2001:ba8:1f1:f004::1337
; Example reverse DNS for 2a0a:1100:1018::1
7.3.3.1.0.0.0.0.0.0.0.0.0.0.0.0 PTR leetv6.example.com
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR another.example.com.
; Example reverse DNS for 2001:ba8:1f1:f004::dead:beef:cafe
; Example reverse DNS for 2a0a:1100:1018::bfbf
e.f.a.c.f.e.e.b.d.a.e.d.0.0.0.0 PTR nomnom.example.com.
f.b.f.b.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR bfbf.example.com.
</syntaxhighlight>
</syntaxhighlight>


You would then need to contact BitFolk support and ask for '''4.0.0.f.1.f.1.0.8.a.b.0.1.0.0.2.ip6.arpa''' to be delegated to your three nameservers '''{a,b,c}.ns.example.com'''.
put this is in a file called for example '''/etc/bind/8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa''', and then reference this file from your '''named.conf''':


You would be advised to use at least two different nameservers in a reverse DNS delegation. If you don't have enough then BitFolk can provide up to three of them, just ask. BitFolk can also provide the only three visible nameservers while taking the zone from your hidden master if you wish.
<syntaxhighlight lang="text">
zone "8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa" {
type master;
file "/etc/bind/8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa";
};
</syntaxhighlight>
 
You would then need to delegate reverse DNS for this domain to your nameservers. This can be configured from [https://panel.bitfolk.com/dns/#toc-ipv6 the IPv6 section of the Panel].
 
You would be advised to use at least two different nameservers in a reverse DNS delegation. If you don't have enough then BitFolk can provide up to three of them, just [[Support|ask]]. BitFolk can also provide the only three visible nameservers while taking the zone from your hidden primary if you wish. In that case you would list the three BitFolk servers in the panel, and if you wish you can firewall your primary server off to BitFolk's internal network only, so that the internet at large can't query it (allow '''85.119.80.222''', '''85.119.80.238''', '''85.119.80.244''', '''2001:ba8:1f1:f040::/64''' and '''2001:ba8:1f1:f25d::/64''' on ''both'' UDP and TCP).


==Routing IPv6==
==Routing IPv6==
The standard BitFolk customer assignment of IPv6 is a /64. This will give you plenty of addresses for your VPS, but isn't enough to route IPv6 further. For example, those using their VPS as a [[Wikipedia:VPN|VPN]] server may wish to route an IPv6 network to each of their clients.
Your /48 assignment can be further subdivided into smaller netblocks. For example, those using their VPS as a [[Wikipedia:VPN|VPN]] server may wish to route an IPv6 network to each of their clients.


It is recommended to use a /64 for each IPv6 network—autoconfiguration won't work if you don't—so if you intend to further route IPv6 then you should contact support to ask for a /56. That will allow up to 256 /64 networks to be routed.
It is recommended to use at least a /64 for each IPv6 network—autoconfiguration won't work if you don't. Your /48 can be subdivided into up to 65.535 /64 networks, or 255 /56 networks.


* [[/VPNs|Using your VPS to provide IPv6 VPNs]]
* [[/VPNs|Using your VPS to provide IPv6 VPNs]]
==Frequently Asked Questions==
===I configured an IPv6 address that's all <tt>f</tt>'s and now I can't reach some sites===
If you configure an address between '''...<tt>:ffff:ffff:ffff:ff80</tt>''' and '''...<tt>:ffff:ffff:ffff:ffff</tt>''' then you might experience strange routing problems for packets sourced from those addresses.
As per [http://tools.ietf.org/html/rfc2526 RFC 2526], the last 128 addresses in each subnet are reserved for [[Wikipedia:IPv6_address#Reserved_anycast_addresses|anycast]] use. While they ''might'' be usable as normal unicast IPv6 addresses, some sites may filter them or they might be used locally.

Latest revision as of 01:06, 31 October 2024

Some notes about configuring IPv6 at BitFolk.

Things changed in October 2024

Warning Warning: Starting in October 2024 BitFolk began assigning customers IPv6 netblocks from a different range, and all existing customer VMs were also assigned blocks from that new range. This article will only discuss the current, up-to-date configuration.

Your IPv6 assignment

By default customers are assigned a /48 of IPv6 space that starts with 2a0a:1100:1. The next three hexadecimal digits will identify your /48. For example:

$ ip -6 address show dev enX0
2: enX0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 2a0a:1100:1018::/128 scope global 
       valid_lft forever preferred_lft forever

This would indicate that 2a0a:1100:1018::/48 is this customer's assignment - the /128 is a single IP address from that assignment.

In this case the very first (all zeroes) address 2a0a:1100:1018:: has been configured, but all addresses between 2a0a:1100:1018:0000:0000:0000:0000:0000 and 2a0a:1100:1018:ffff:ffff:ffff:ffff:ffff are available to the customer for assignment (280-1 addresses).

As with IPv4, your IPv6 assignment is listed in the Panel.

Static IPv6 configuration

Dynamic IPv6 address allocation is not used at BitFolk.

Configuring additional IPv6 addresses

ifupdown (Debian)

ifupdown is currently the default network configuration framework on Debian. Other popular options are netplan or systemd-networkd directly. It is also possible to use NetworkManager, though that is usually only used on Debian desktop systems.

ifupdown is configured with the /etc/network/interfaces file (or in files included from that file). Your starting configuration will look something like this, covering both IPv4 and IPv6:

auto enX0
iface enX0 inet static
    address 85.119.82.121/21
    gateway 85.119.80.1

iface enX0 inet6 static
    address 2a0a:1100:1018::/128
    gateway fe80::1
    # This blackhole route is REQUIRED by BitFolk policy in order to prevent
    # traffic for unused addresses looping back out. It will not affect any
    # directly added IP address or route you have. Please do not remove it!
    #
    # If you do not like traffic to unknown adresses being silently dropped you
    # can change "blackhole" to "prohibit" which will result in your host
    # kernel sending back an ICMP Communication with Destination
    # Administratively Prohibited (type 1, code 1) message.
    #
    # Using firewall rules for the same purpose would also be acceptable.
    # ⬇️⬇️⬇️ Please do not remove
    post-up ip route add blackhole 2a0a:1100:1000::/48
    # ⬆️⬆️⬆️ Please do not remove

To add another IPv6 address simply add another iface block lower down:

iface enX0 inet6 static
    address 2a0a:1100:1018::1/128

It will not require a gateway directive.

netplan (Ubuntu 18.04 onwards)

Just add more IPv6 addresses to the addresses: list in the config file (e.g. /etc/netplan/01-netcfg.yaml):

network:
  version: 2
  ethernets:
    enX0:
      addresses:
        - "85.119.82.121/21"
        - "2a0a:1100:1018::/128"
        - "2a0a:1100:1018::1/128"
      routes:
        - to: default
          via: "85.119.80.1"
        - to: default
          via: "fe80::1"
        - to: "2a0a:1100:1018::/48"
          via: "::"
          type: blackhole
      nameservers:
        addresses:
          - "85.119.80.232"
          - "85.119.80.233"
          - "2001:ba8:1f1:f205::53"
          - "2001:ba8:1f1:f206::53"

To update the config and then make it live:

$ sudo netplan try

This will ask you for confirmation that everything is still working. If you don't provide it within a few seconds it will revert the change.

NetworkManager (CentOS and other Red Hat-like systems)

CentOS and other Red Hat-like systems use NetworkManager by default. This can be reconfigured live on the command line using nmcli.

To add an extra IPv6 address:

# nmcli connection modify enX0 +ipv6.addresses 2a0a:1100:1018::1/128


systemd-networkd

Help?

The default IPv6 source address

The source address chosen for IPv6 packets is typically the last one added to the system. This may be undesirable if you are adding addresses that you wish to dedicate to certain services. You can force a particular IPv6 address to be used as source by marking all the other addresses as deprecated. Deprecated addresses will still receive traffic and can still source traffic if they are specifically requested, but by default will not be used as a source address. You mark an IPv6 address as deprecated by setting its preferred_lft to 0.

Deprecating existing addresses

Given the following IPv6 setup:

$ ip -6 addr show dev enX0
2: enX0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 2a0a:1100:1018::/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 2a0a:1100:1018::1/128 scope global 
       valid_lft forever preferred_lft forever

Here 2a0a:1100:1018::1 will most likely be used as a source address because it was added last. In order to force 2a0a:1100:1018:: to be used, you can use ip address change to deprecate the other one:

# ip address change 2a0a:1100:1018::1 dev enX0 preferred_lft 0
# ip address show dev enX0
2: enX0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 2a0a:1100:1018::1/128 scope global deprecated 
       valid_lft forever preferred_lft 0sec
    inet6 2a0a:1100:1018::/128 scope global 
       valid_lft forever preferred_lft forever

To make the change permanent you'll need to set it in your network configuration.

Debian

# This one is to be the one that is used for outbound traffic by default
iface enX0 inet6 static
    address 2a0a:1100:1018::/128
    gateway fe80::1
    # skipped all the stuff about blackhole route in this example

# Perhaps you will only use this one for web serving
iface enX0 inet6 static
    address 2a0a:1100:1018::80/128
    preferred-lifetime 0

# Add another IPv6 address. If it wasn't for the use of
# preferred-lifetime 0 this one would probably be the default source
# address as it was added last
iface enX0 inet6 static
    address 2a0a:1100:1018::bfbf/128
    preferred-lifetime 0

netplan (Ubuntu 18.04 onwards)

In netplan configuration you can set the preferred_lft on any address in the addresses: list:

      addresses:
        - "85.119.82.121/21"
        - "2a0a:1100:1018::/128"
        - "2a0a:1100:1018::1/128":
            lifetime: 0

NetworkManager (CentOS and other Red Hat-like systems)

We haven't been able to work out if NetworkManager can set the preferred_lft of individual addresses apart from autogenerated addresses. Please update if you know how.

It may be possible to use a hook script to run the equivalent ip address change … preferred_lft 0 command.

In general, addresses defined with nmcli connection modify enX0 ipv6.addresses … are in decreasing order of priority, so the first one is the preferred source address.

Firewalling

Don't forget that you'll need to firewall your IPv6 just like you firewall your IPv4. The tool to do so is either nft (current) or ip6tables (deprecated).

Neighbor Discovery

IPv6 uses neighbor discovery to map IPv6 addresses to Ethernet (MAC) addresses. This replaces the functionality of ARP in IPv4, and as a result means you do need to allow some types of ICMPv6 traffic through if you want anything at all to work:

nft

Help?

ip6tables

--append INPUT -p ipv6-icmp --icmpv6-type neighbor-advertisement -j ACCEPT
--append INPUT -p ipv6-icmp --icmpv6-type neighbor-solicitation  -j ACCEPT

Alternatively you may just want to allow everything on link-local addresses:

--append INPUT -s fe80::/10 -j ACCEPT

Preferring IPv4 over IPv6

Sometimes a remote host will have both IPv4 and IPv6 addresses. By default, Linux tends to prefer IPv6. If for some reason you wish to prefer IPv4 addresses then you can do so by adding:

precedence ::ffff:0:0/96 100

at the end of /etc/gai.conf .

Disabling IPv6

If you don't use IPv6 yet then it might be best to explicitly disable it.

Kernel level

Arranging for ipv6.disable=1 to be added to the kernel's command line should work on any Linux distribution from its next boot.

Debian/Ubuntu

IPv6 can be disabled with a sysctl, for example:

# echo 'net.ipv6.conf.all.disable_ipv6=1' > /etc/sysctl.d/disableipv6.conf

As IPv6 support is built into the kernel this will disable IPv6 from the next reboot.

CentOS and other Red Hat-like systems

Unknown if NetworkManager will obey the above sysctl. Let us know?

Reverse DNS

Automated IPv6 reverse DNS (default)

By default you have generic automatic reverse DNS for IPv6 that looks a bit like this:

$ dig +noall +answer -x 2a0a:1100:1018::
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa. 3600 IN PTR 2a0a-1100-1018-0-0-0-0-0.autov6rev.bitfolk.space.
 dig +noall +answer -t aaaa 2a0a-1100-1018-0-0-0-0-0.autov6rev.bitfolk.space.
2a0a-1100-1018-0-0-0-0-0.autov6rev.bitfolk.space. 3600 IN AAAA 2a0a:1100:1018::

As you can see, it resolves correctly both ways.

Controlling your own IPv6 reverse DNS

If instead you would like to take control of your IPv6 reverse DNS then BitFolk can delegate the reverse DNS for your zone to nameservers you specify. These can all be nameservers you control, or BitFolk can provide up to three of them (you just provide the primary: see the page on secondary DNS for more information.)

The reverse zone for 2a0a:1100:1018::/48 would be called 8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa. You can work this out using dig. For example:

$ dig +noall +question -x 2a0a:1100:1018::
;0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa. IN PTR

or sipcalc:

$ sipcalc -ar 2a0a:1100:1018::
-[ipv6 : 2a0a:1100:1018::] - 0

[IPV6 INFO]
Expanded Address        - 2a0a:1100:1018:0000:0000:0000:0000:0000
Compressed address      - 2a0a:1100:1018::
Subnet prefix (masked)  - 2a0a:1100:1018:0:0:0:0:0/128
Address ID (masked)     - 0:0:0:0:0:0:0:0/128
Prefix address          - ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
Prefix length           - 128
Address type            - Aggregatable Global Unicast Addresses
Network range           - 2a0a:1100:1018:0000:0000:0000:0000:0000 -
                          2a0a:1100:1018:0000:0000:0000:0000:0000

[V4INV6]
Expanded v4inv6 address - 2a0a:1100:1018:0000:0000:0000:0.0.0.0
Compr. v4inv6 address   - 2a0a:1100:1018::0.0.0.0

[IPV6 DNS]
Reverse DNS (ip6.arpa)  -
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa.

-


The 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 part is the record you put in your zone and the 8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa is the name of the zone itself. Here is what a typical BIND-format zone file might look like:

$ORIGIN 8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa.
$TTL 10800      ; 3 hours
@                       IN SOA a.ns.example.com. hostmaster@example.com. (
                             2024103101   ; serial
                                   1800   ; refresh (30 mins)
                                    900   ; retry (15 mins)
                                1209600   ; expire (2 weeks)
                                   3600 ) ; minimum (20 mins)

                                NS a.ns.example.com.
                                NS b.ns.example.com.
                                NS c.ns.example.com.

; Example reverse DNS for 2a0a:1100:1018::
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR ruminant.example.com.
; Example reverse DNS for 2a0a:1100:1018::1
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR another.example.com.
; Example reverse DNS for 2a0a:1100:1018::bfbf
f.b.f.b.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 PTR bfbf.example.com.

put this is in a file called for example /etc/bind/8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa, and then reference this file from your named.conf:

zone "8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa" {
	type master;
	file "/etc/bind/8.1.0.1.0.0.1.1.a.0.a.2.ip6.arpa";
};

You would then need to delegate reverse DNS for this domain to your nameservers. This can be configured from the IPv6 section of the Panel.

You would be advised to use at least two different nameservers in a reverse DNS delegation. If you don't have enough then BitFolk can provide up to three of them, just ask. BitFolk can also provide the only three visible nameservers while taking the zone from your hidden primary if you wish. In that case you would list the three BitFolk servers in the panel, and if you wish you can firewall your primary server off to BitFolk's internal network only, so that the internet at large can't query it (allow 85.119.80.222, 85.119.80.238, 85.119.80.244, 2001:ba8:1f1:f040::/64 and 2001:ba8:1f1:f25d::/64 on both UDP and TCP).

Routing IPv6

Your /48 assignment can be further subdivided into smaller netblocks. For example, those using their VPS as a VPN server may wish to route an IPv6 network to each of their clients.

It is recommended to use at least a /64 for each IPv6 network—autoconfiguration won't work if you don't. Your /48 can be subdivided into up to 65.535 /64 networks, or 255 /56 networks.

Frequently Asked Questions

I configured an IPv6 address that's all f's and now I can't reach some sites

If you configure an address between ...:ffff:ffff:ffff:ff80 and ...:ffff:ffff:ffff:ffff then you might experience strange routing problems for packets sourced from those addresses.

As per RFC 2526, the last 128 addresses in each subnet are reserved for anycast use. While they might be usable as normal unicast IPv6 addresses, some sites may filter them or they might be used locally.