获取最新有效期 ipv6 地址
Author: tuxsuCreated Nov 25, 2024Updated Jan 4, 2026
Labelsenhancementkeep
Description
获取最新valid_lft时间的ipv6
ip a命令可以查看到网口ip地址,存在多个ipv6,每个ipv6都有valid_lft和preferred_lft时间,获取最新的valid_lft有效时间(最大值);当然你可以用将下面命令中valid_lft换成preferred_lft(其实两者效果一样)- 使用
valid_lftip -6 a | awk -F '[ \t]+|/' '/inet6/ && $3 ~ /^(2408|2409|240e)(:|::)/ {ipv6=$3; getline; if ($2=="valid_lft") {split($3,t,"sec"); if(t[1]>max) {max=t[1]; best=ipv6}}} END {print best}' - 使用
preferred_lftip -6 a | awk -F '[ \t]+|/' '/inet6/ && $3 ~ /^(2408|2409|240e)(:|::)/ {ipv6=$3; getline; if ($4=="preferred_lft") {split($5, t, "sec"); if (t[1] > max) {max=t[1]; best=ipv6}}} END {print best}'
Problem
No response
Other Description
No response
Checklist
- I am using the latest version and have confirmed that the feature is not yet implemented in the latest version
- I have searched for similar feature requests before submitting this one
Source: jeessy2/ddns-go