Skip to content
New issue

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

[debug]取本地ipv6地址时出错 #387

Open
ghost opened this issue Jan 30, 2023 · 1 comment
Open

[debug]取本地ipv6地址时出错 #387

ghost opened this issue Jan 30, 2023 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Jan 30, 2023

描述问题 (Describe the bug)

取本地ipv6地址时出错,想要直接取本地网卡(ens33)的ipv6地址(光猫直接分配的),在getaddrinfo时出错。

版本信息 (version info)

  • DDNS Version: v2.12.0@2022-12-07
  • OS Version: ubuntu18.04
  • Type(运行方式): Python3
  • related issues (相关问题):

复现步骤 (To Reproduce)

配置config.json,执行ddns -c config.json
ip addr 执行显示ens33是第二个网卡

配置文件 (config file)

config.json
{
"token": "xxxxxxxxxxxxxx",
"dns": "cloudflare",
"ipv4": [],
"ipv6": ["xxx.yyyyy.com"],
"index6": 1,
"debug": true
}

调试输出 (debug output)

Traceback (most recent call last):
File "/usr/local/bin/ddns", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.8/dist-packages/run.py", line 151, in main
update_ip('6', cache, dns, proxy_list)
File "/usr/local/lib/python3.8/dist-packages/run.py", line 97, in update_ip
address = get_ip(ip_type, index_rule)
File "/usr/local/lib/python3.8/dist-packages/run.py", line 51, in get_ip
value = getattr(ip, "local_v" + ip_type)(index)
File "/usr/local/lib/python3.8/dist-packages/util/ip.py", line 38, in local_v6
info = getaddrinfo(gethostname(), 0, AF_INET6)
File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -5] No address associated with hostname

补充说明 (Additional context)

/etc/hosts中配置为127.0.1.1 ubuntu
手动执行getaddrinfo(gethostname(), 0, AF_INET)时返回的是127.0.0.1,好像ipv4也没有达到获取某网卡地址的功能,这个功能原想法应该不是想要获取lo回环地址吧?

现在暂时用default方式实现的。

@ghost ghost added the bug label Jan 30, 2023
@ghostLiulang
Copy link

我是使用shell的形式进行获取ipv6地址
"index6": "shell: /usr/sbin/ifconfig eth0 | egrep -o '24.*:.*:[a-z0-9]{3,4}:[a-z0-9]{3,4}' | head -n 1",
这段代码在树莓派4B (基于debian 12)上是可以运行的.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant