Get only one IPv6 address on clients question

Right. Thanks for the reminder.. and I would agree that this would be hardly useful.

With dynamic prefixes from an ISP that is no real option.

Let me ask you again from the beginning: what's the issue?
You could just use the default behavior and openwrt will add DNS for ipv4 and IPv6 client addresses. I think in the default config you also get point to resource records so you can resolve also IP to domain.

I am using all default configs by openwrt for IPv6 except I added few static leases with '''option hostid''' (Get only one IPv6 address on clients question)

My issue (was),
on the clients when I look for ifconfig, there is my static lease hostid IPv6 address and some other IPv6 address.
I wanted to grab only the static lease hostid IPv6 address and map to my ddns.

I solved the issue by Get only one IPv6 address on clients question - #4 by simtcrom

Just as an addon...

DHCPv6 leases are /128, so we can use that. Sadly, ULA is also scope global, so we need to filter that somehow.

I would at least(!) use ip -oneline.

I don't want to judge which looks better, pipe grep foo, or iproute2 json and jq... but let choose that one, which has lower changes to break if you look at it from the side...

ULA="fde6:a09a:b373"
ip -j -6 addr show eno1 scope global | jq ".[] | .addr_info[] | select( .prefixlen==128 ) | select( .local | contains( \"${ULA}\" ) | not )"
{
  "family": "inet6",
  "local": "2003:XX:XXX:XX40::xxx",
  "prefixlen": 128,
  "scope": "global",
  "dynamic": true,
  "noprefixroute": true,
  "valid_life_time": 25203,
  "preferred_life_time": 25203
}

For those not familiar with jq-syntax:
Use all elements of the top-level-array;
use .addr_info-array;
select those elemts which contain a .prefixlen of 128; and
filter out these that come from the ULA-prefix....

EDIT:
Sorry of course you only wanted the GUA:

ip -j -6 addr show eno1 scope global \
| jq -r ".[] | .addr_info[] | select( .prefixlen==128 ) | select( .local | contains( \"${ULA}\" ) | not ) | .local"
2003:XX:XXXX:XX40::xxxx
2 Likes

Thank you I will try this.

Yes, but only the interface identifier (last 64 bits of the address). The prefix is still learned via SLAAC. You need to check how to configure this on your system, but here is an example for systemd-networkd (see IPv6Token):

[Match]
Name=enp3s0
[Network]
DHCP=yes
IPv6Token=::100
IPv6PrivacyExtensions=no
IPv6AcceptRA=yes
1 Like

I am still learning IPv6, so thank you for being patient with me.

Assuming my client is raspberry pi (Linux) any idea which file I need to put these lines on?

I modified it slightly to make it work for me as below,

ip -j -6 addr show eth0 scope global | jq -r ".[] | .addr_info[] | select( .prefixlen==128 ) | select( .local | contains( \"<MY GUA STARTING 4 digits>\" )  ) | .local"

However on openwrt system itself ip -j -6 addr show is not working. Response is,

root@OpenWrt:~# ip -j -6 addr show
BusyBox v1.36.1 (2024-12-23 00:55:35 UTC) multi-call binary.

Usage: ip [OPTIONS] address|route|link|neigh|rule [ARGS]

OPTIONS := -f[amily] inet|inet6|link | -o[neline]

ip addr add|del IFADDR dev IFACE | show|flush [dev IFACE] [to PREFIX]
ip route list|flush|add|del|change|append|replace|test ROUTE
ip link set IFACE [up|down] [arp on|off] [multicast on|off]
        [promisc on|off] [mtu NUM] [name NAME] [qlen NUM] [address MAC]
        [master IFACE | nomaster] [netns PID]
ip neigh show|flush [to PREFIX] [dev DEV] [nud STATE]
ip rule [list] | add|del SELECTOR ACTION

Check what rasbian is using nowadays, but if it's systemd-networkd you can create a new config. Check the docs.

You need the package ip-full.

Got it.
ran opkg install ip-full
Then

ip -j -6 addr show br-lan scope global | jq -r ".[] | .addr_info[] | select( .prefixlen==64) | select( .local | contains( \"<MY GUA STARTING 4 digits>\" )) | .local"

According to the documentation, the latest Raspberry Pi OS uses NetworkManager.

You should be able to specify an interface identifier like this:

nmcli connection modify "name of connection" ipv6.addr-gen-mode eui64
nmcli connection modify "name of connection" ipv6.token ::abcd

And to go back to the original configuration:

nmcli connection modify "name of connection" ipv6.token ""
nmcli connection modify "name of connection" ipv6.addr-gen-mode default

Thank you.
How do I know the name of connection?
ipv6.token ::abcd and this as ipv6.token ::06 ?

List the names, use tab completion, use show to inspect the connection details.

1 Like

Tab completion as already mentioned, is a good option. Otherwise, try nmcli connection show.

And don't forget to apply the changes by reconnecting: nmcli connection up "connection name"

2 Likes

Thank you that worked,

To set ipv6 with suffix ::09,

sudo nmcli connection show
sudo nmcli connection modify "Wired connection 1" ipv6.addr-gen-mode eui64
sudo nmcli connection modify "Wired connection 1" ipv6.token ::09
sudo reboot

to go back.

sudo nmcli connection modify "Wired connection 1" ipv6.token ""
sudo nmcli connection modify "Wired connection 1" ipv6.addr-gen-mode default
sudo reboot

I also noticed that, since I had the router reservation set I got two IPv6 ips with suffix ::06 and ::09

I find this much convenient than depending on router DHCP reservation (DUID mess and router restarts needed)

1 Like