IPv6

Get Your VPS IPv6 Address

January 29th, 2024|Guides, Techy Stuff|
Share

Chances are you’ll know your VPS IPv4 address if your plan has one as your provider will email it to you on signup and it’ll feature prominently in your accounts control panel. Identifying your servers IPv6 address can be a bit more involved, but necessary if you’d like to configure an AAAA record for your domain’s DNS to allow connectivity by IPv6.

The quick answer is to run the following command and then select the output on ETH0 (or ETHn), with a ‘global’ scope that is valid (valid_lft) ‘forever’.

Bash
ip -6 a

The above command, while filtering out those without the correct scope or validity period, will get you the IPv6 address for public access.

Exploring this further, there is a chance you’ll get an output similar to the following with just two interfaces.

Bash
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
    inet6 ::1/128 scope host noprefixroute
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
    inet6 2606:6680:43:1::5156:5869/48 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::216:3cff:fefc:ad4a/64 scope link
       valid_lft forever preferred_lft forever

Alternatively you could get something convoluted like the following

Bash
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
    inet6 ::1/128 scope host noprefixroute
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
    inet6 2607:9000:7000:23:216:3cff:feb1:51cb/64 scope global dynamic mngtmpaddr
       valid_lft 2591908sec preferred_lft 604708sec
    inet6 2607:1e40:1:119b::8ac9/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::216:3cff:feb1:51cb/64 scope link
       valid_lft forever preferred_lft forever
3: br-ae5780d586ad: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
    inet6 fe80::42:cbff:fe61:3eb4/64 scope link
       valid_lft forever preferred_lft forever
6: veth5df00ca@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
    inet6 fe80::8aa:14ff:fe10:db5/64 scope link
       valid_lft forever preferred_lft forever
8: vethf0ae3e2@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
    inet6 fe80::b061:b5ff:fe01:7c86/64 scope link
       valid_lft forever preferred_lft forever
10: vethe73da77@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
    inet6 fe80::a0ff:60ff:fea5:37fa/64 scope link
       valid_lft forever preferred_lft forever
12: veth53cd3a3@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP
    inet6 fe80::e03e:f9ff:feb0:bcd6/64 scope link
       valid_lft forever preferred_lft forever

In both cases above, eth0 is the adapter to use. This is the physical ethernet adapter associated with the system. Those prefixed with a ‘v’ are virtual, lo is an internal adapter and as per bellow, the adapter ‘br-ae5780d586ad’ is missing a public address (as are all the virtual interfaces).

After the adapter is identified, look at the scope of the addresses. With IPv6 you will have at least 2x addresses on an adapter that supports access from remotely, an external (global) one and an internal (link) scope. The link scope is for traffic within the network, while the global is externally accessible. In example one above this means that the public IPv6 can be quickly narrowed down to “2606:6680:43:1::5156:5869”.

You will notice that in the second example there are two global IP addresses. There are two further pieces of information that identify the correct address to use. The first is that one includes the identifier ‘mngtmpaddr’, which denotes this as a temporary address used by the kernel. Additionally observe that the lifetime of the same address (valid_lft) is ‘2591908sec’. The other global address however has a lifetime (valid_lft) of ‘forever’. If you are using the IPv6 address for mapping an AAAA with your domains DNS, then you obviously want this to be a stable address that will not expire. As such in example two, our public IPv6 is “2607:1e40:1:119b::8ac9”.

Conclusion

The above will help you identify the public IPv6 associated with your server. This can then be used to populate DNS with an AAAA record which will allow connectivity to your site/server via IPv6.