You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I experienced similar issues and I noted that ipify has an interface for IPv6 and it does exactly what I need (returns the correct IPv6 globally routable address for the device that I run the script on).
I would suggest the following change: def get_ipv6_address(interface_name): return requests.request("GET", "https://api6.ipify.org").text
My curiosity got the better of me and I took a second look ...
The issue for me that kept the script from working as is was the grep statement looking to exclude "mngtmpaddr", which would be leveraging RFC3041 to allow the kernel to manage temporary addresses. The other exclusion, "temporary" is for RFC4941 addressing to mask a permanent address and it is not recommended to use temporary addressing for server use, but more for outbound connectivity, so makes sense to exclude. I also discovered per the man page for ip-address (8) that there are flags that you can use instead of the grep, fwiw that would be "-temporary" and "-mngtmpaddr" to get the same result.
It seems that most Linux configuration defaults leave the "mngtmpaddr" set. This does indicate another potential issue as this is not truly a "permanent" address and I should likely modify the way the address is assigned or the netplan.
I understand there can be a myriad of scenarios and you wrote the script for what worked for you, but a fix that may work for more environments if not using the ipify API could be to remove the "mngtmpaddr" restriction and just skip temporary addresses, quasi-diff as follows -
< ip_output = subprocess.getoutput(f"ip -6 -o address show dev {interface_name} scope global | grep --invert temporary | grep --invert mngtmpaddr") > ip_output = subprocess.getoutput(f"ip -6 -o address show dev {interface_name} scope global -temporary")
Regardless, appreciate the script as got me quickly to what I needed with just a minor tweak.
This is the only output in my logfile, IPv6 is activated on my system
The text was updated successfully, but these errors were encountered: