Set Static IPv6 Address on Eth0 at Command Line?


Is it possible to set my eth0 interface to a static IPv6 address? I have a docker container I need to hardcode the Server (docker host) IP into. It's choking on me a bit, and I just realized my pi's LAN IP is definitely changing.

My router's IPv6 support is anemic at best. Getting it to hand out v6 addresses internally took hours. I can't set static v6 addresses there.

I found this thread, but assumes GUI access, and command line tools that might be Raspbian-only...

I don't have a GUI at the moment. I'm on SSH; whatever I do needs to not make it impossible to shell in. :slight_smile:


At first, you need to find out which software you use to set up your networking. Do you use NM, networkd, dhcpd,...? Pick one, make sure you use only one. Then configure that one.

The nice thing with IPv6 is that you can easily add multiple address to one interface. You should at least use the none privacy address with "ff:fe" in the host part, you also can add a short one like "prefix::2" Which is easier to remember.

Keep in mind that your Prefix might change. This depends on your ISP. Some change it regularly other only if you reboot the router or only once a year.

You also cloud set up a local prefix or use the link local address fe80:: which don't change, but are harder to use.

1 Like

Thanks for your message.

How do I tell from the command line what software controls the network settings? I'm running the ARM XFCE distribution. Maybe I should have asked this over in the ARM forum? Once I can get back into the GUI, I'll have access to Network Manager, so I'll likely use that interface. I see no reason to try to flex on the command line when I don't fully understand what I'm doing yet.

Here's my current wired ethernet interface. Things that look like MAC addresses are removed.
The bolded portion of the inet6 address is the Prefix according to my router, which is set up for DHCPv6-PD. Doing it any other way on the router does not work.

I have no idea when or if the prefix changes.

I see the valid_lft and preferred_lft (valid & preferred lifetime) flag on the local v6 loop is undying, but on the global address is ~21.6 hours.

What do you think is the best way to go to try and fix this?

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether $MAC
inet $v4HOST brd $v4Subnet scope global dynamic noprefixroute eth0
valid_lft 77895sec preferred_lft 77895sec
inet6 2605:6000:1521:83c4:e360:a8ba:fe5e:80bd/64 scope global dynamic noprefixroute
valid_lft 604769sec preferred_lft 604769sec
inet6 $MAC/64 scope link noprefixroute
valid_lft forever preferred_lft forever

Find out which software you use to set up your Network is most important. You don't need a GUI for this. Simply check which systemd services are active.

systemctl list-unit-files | grep enabled

Back in the days, Manjaro Arm used to enable at least 2 sometimes 3 different network set up softwares. It was a really big mess. Hopefully it has changed.

You can configure NM without a GUI, nmcli is not that intuitive. But you can configure everything. There is a second one, don't use it, it has not all the options.

On a headless server, systemd-networkd is a good choice.

Your output shows a IPv6 address that uses the privacy extension. It is a good fit for a private computer, but not for a server. It will also change.
After you found out which software you use, you should change it.

You also see the link local address, it is the one starting with fe80::

It can be used to connect to your system too.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by