We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
valid_lft
ip a命令可以查看到网口ip地址,存在多个ipv6,每个ipv6都有valid_lft和preferred_lft时间,获取最新的valid_lft有效时间(最大值);当然你可以用将下面命令中valid_lft换成preferred_lft(其实两者效果一样)
ip a
preferred_lft
使用valid_lft
ip -6 addr | awk -F '[ \t]+|/' '/inet6/ && $3 != "::1" && $3 !~ /^fe80::/ && $3 !~ /^fda8:/ {ipv6=$3; getline; if ($2=="valid_lft") {split($3, t, "sec"); if (t[1] > max) {max=t[1]; best=ipv6}}} END {print best}'
使用preferred_lft
ip -6 addr | awk -F '[ \t]+|/' '/inet6/ && $3 != "::1" && $3 !~ /^fe80::/ && $3 !~ /^fda8:/ {ipv6=$3; getline; if ($4=="preferred_lft") {split($5, t, "sec"); if (t[1] > max) {max=t[1]; best=ipv6}}} END {print best}'
$3 !~ /^fe80::/是用于排除已fe80::开头的ipv6;需要排除其他已xxxx开头的ipv6自行添加
$3 !~ /^fe80::/
fe80::
xxxx
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
获取最新
valid_lft
时间的ipv6ip a
命令可以查看到网口ip地址,存在多个ipv6,每个ipv6都有valid_lft
和preferred_lft
时间,获取最新的valid_lft
有效时间(最大值);当然你可以用将下面命令中valid_lft
换成preferred_lft
(其实两者效果一样)使用
valid_lft
使用
preferred_lft
$3 !~ /^fe80::/
是用于排除已fe80::
开头的ipv6;需要排除其他已xxxx
开头的ipv6自行添加Problem
No response
Other Description
No response
Checklist
The text was updated successfully, but these errors were encountered: