Score:0

How to disable temporary dynamic ipv6 addresses in Ubuntu 21.10?

us flag

By default Ubuntu 21.10 (should be the same for 20.04) does generate temporary/privacy IPV6 addresses. I would like to disable this behavior in order to make my computer into a server, and to do so I would like to have an IPV6 address as stable as possible (notably to ease of process of configuring a DNS name without using DDNS, at least for the IPV6 address).

When looking at ip -6 address it looks like this:

    inet6 2a02:a03f:a0bb:abcd:ea4b:d152:592e:74da/64 scope global temporary dynamic 
       valid_lft 83659sec preferred_lft 69259sec
    inet6 2a02:a03f:a0bb:abcd:3c0d:e2ad:569e:2536/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 83659sec preferred_lft 69259sec

I want an autoconfigured permanent addresses like this (taken from a server in the same network, the address seem to have been generated using the modified EUI-64 algorithm):

    inet6 2a02:a03f:a0bb:abcd:211:32ff:fe59:76be/64 scope global dynamic 
       valid_lft 64840sec preferred_lft 50440sec

Please note I don't want to configure a static IPV6address!

That's why I ask this question today. Most Google searchs about this issue ends in nonsensical advice explaining how to configure a static IPV6 address. It's not the same thing than a permanent autoconfigured address. To generate those the OS must listen for the router to get the first 64 bits of the address and the complete the remaining bits with its MAC address.

cyberbrain avatar
cn flag
Do you mean to disable IPv6 privacy extensions and use EUI64 for IPv6 address generation mode?
us flag
Yep, that's what I mean.
Thomas Aichinger avatar
cn flag
You should have a properly configured dhcp v6 service listening where your nic is connected to and then you can disable v6 autoconf.
us flag
This comment doesn't help. I already have a dhcp service on my router or I wouln't have ipv6 connectivity at all. This issue is not related to the dhcp service configuration as it is caused by IPv6 privacy extensions on my Ubuntu machine as stated by cyberbrain previously. Also, I don't want to disable ipv6 autoconfiguration since, as far as I know, this would force me to configure as purely static ipv6 address which is not what I want to do as I stated it in the question.
Score:0
us flag

Best solution I've found until now was taken from here

In a nutshell we execute these commands as root:

cat >> /etc/sysctl.conf <<EOT
net.ipv6.conf.all.use_tempaddr=0
net.ipv6.conf.default.use_tempaddr=0
EOT

sysctl -p

After rebooting it gives the following result:

inet6 2a02:a03f:a0bb:abcd:3c0d:e2ad:5693:2536/64 scope global dynamic noprefixroute 
   valid_lft 64209sec preferred_lft 49809sec

It does seem to be a permanent IPV6 address.

A few comments:

  • Strangely this address does not follow the modified EUI-64 algorithm scheme as I can't see the expected FF:FE that this algorithm is supposed to always yield. I suppose it's a bad thing because it could mean that this address could be "forgotten", as example if I completely reinstall my computer. (And it would be cool if it didn't because having addresses that can even survive a complete SSD/HDD crash does seem interesting.)
  • After some more search I'm not sure anymore it is necessary to disable this IPV6 temporary address in order to make a server (which was my intention). It seems like the second ip address (the one with scope global dynamic mngtmpaddr noprefixroute) is the same as the one I get by disabling temporary address and is actually pingable. So I might actually just use that address in order to reach my server.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.