Skip to content

Commit

Permalink
希望能更改linux系统下,index6 正则获取本地ip的命令优先级 (#441)
Browse files Browse the repository at this point in the history
更改linux系统下,index6 正则获取本地ip的命令优先级

优先使用ip address 而非ifconfig,理由如下:
ifconfig 会先匹配到处于弃用(Deprecated)状态的v6 ip,不会把处于弃用的v6放到末尾,导致提交的dns v6解析记录为过期v6 ip。

而ip address获取到的前两个ip均为有效前缀v6 ip,可能是对lifetime 或者 ip 获得时间进行过排序

ipaddr 与 win 系统下的ipconfig ip顺序一致,符合“排序”期望

故希望在linux系统中,优先考虑使用ipaddr 而非 ipconfig
  • Loading branch information
Elec4d0 authored Jun 27, 2024
1 parent 732c5f8 commit 7781861
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _ip_regex_match(parrent_regex, match_regex):
if os_name == 'nt': # windows:
cmd = 'ipconfig'
else:
cmd = 'ifconfig 2>/dev/null || ip address'
cmd = 'ip address || ifconfig 2>/dev/null'

for s in popen(cmd).readlines():
addr = ip_pattern.search(s)
Expand Down

0 comments on commit 7781861

Please sign in to comment.