TreviD / aliddns

aliddns by python
MIT License
60 stars 53 forks source link

群晖IPV6问题 #11

Open czxinshui opened 4 years ago

czxinshui commented 4 years ago

你好,群晖的有时候会获取到2个IPV6的地址,一个F开头,一个24开头。F的是内网地址,24是公网地址,请问能否加一条命令,只读24开头的IPV6

TreviD commented 4 years ago

已修改成优先通过网络获取ipv6地址,我不具备ipv6环境,麻烦测试下,有结果请反馈!多谢!

czxinshui commented 4 years ago

你好,第245行代码 ''' ip addrshow eth0 | grep "inet6.*global" | awk '{print $2}' | awk -F"/" '{print $1}' ''').readlines() # 这个返回值是一个list 是不是查看eth0的IPV6,我群晖的IVP6地址是ovs_eth0 请问我这边是否需要修改

czxinshui commented 4 years ago

Traceback (most recent call last): File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 1240, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1083, in request self._send_request(method, url, body, headers) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1128, in _send_request self.endheaders(body) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1079, in endheaders self._send_output(message_body) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 911, in _send_output self.send(msg) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 854, in send self.connect() File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1229, in connect super().connect() File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 826, in connect (self.host,self.port), self.timeout, self.source_address) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/socket.py", line 693, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/volume1/@appstore/py3k/usr/local/lib/python3.5/socket.py", line 732, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/volume2/homes/water/aliddns/aliddns.py", line 306, in ip = get_local_ipv6() File "/volume2/homes/water/aliddns/aliddns.py", line 275, in get_local_ipv6 ipv6Addr = get_Local_ipv6_address_win() File "/volume2/homes/water/aliddns/aliddns.py", line 209, in get_Local_ipv6_address_win content = urllib.request.urlopen(pageURL).read() File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 162, in urlopen return opener.open(url, data, timeout) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 465, in open response = self._open(req, data) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 483, in _open '_open', req) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 443, in _call_chain result = func(*args) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 1283, in https_open context=self._context, check_hostname=self._check_hostname) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 1242, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

TreviD commented 4 years ago

你好,更新一下脚本,现在已经改成优先从网络获取ipv6,不是从本地获取了,再看下是否还有问题?

czxinshui commented 4 years ago

你好,还是一样,都是这个代码Traceback (most recent call last): File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 1240, in do_open h.request(req.get_method(), req.selector, req.data, headers) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1083, in request self._send_request(method, url, body, headers) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1128, in _send_request self.endheaders(body) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1079, in endheaders self._send_output(message_body) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 911, in _send_output self.send(msg) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 854, in send self.connect() File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 1229, in connect super().connect() File "/volume1/@appstore/py3k/usr/local/lib/python3.5/http/client.py", line 826, in connect (self.host,self.port), self.timeout, self.source_address) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/socket.py", line 693, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/volume1/@appstore/py3k/usr/local/lib/python3.5/socket.py", line 732, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/volume2/homes/water/aliddns/aliddns.py", line 306, in ip = get_local_ipv6() File "/volume2/homes/water/aliddns/aliddns.py", line 275, in get_local_ipv6 ipv6Addr = get_Local_ipv6_address_win() File "/volume2/homes/water/aliddns/aliddns.py", line 209, in get_Local_ipv6_address_win content = urllib.request.urlopen(pageURL).read() File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 162, in urlopen return opener.open(url, data, timeout) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 465, in open response = self._open(req, data) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 483, in _open '_open', req) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 443, in _call_chain result = func(*args) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 1283, in https_open context=self._context, check_hostname=self._check_hostname) File "/volume1/@appstore/py3k/usr/local/lib/python3.5/urllib/request.py", line 1242, in do_open raise URLError(err) urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

czxinshui commented 4 years ago

你好,还是无法运行成功

czxinshui commented 4 years ago

能不能做一个IPV6群晖专享的,

TreviD commented 4 years ago

确定你的群晖有ipv6环境?我看错误提示是域名解析失败了。。

czxinshui commented 4 years ago

有啊。用原来没改的代码还是可以用的 https://drive.google.com/file/d/1MHpslKya-0UCat2Dexou_qZZjqo6qf_o/view?usp=sharing

TreviD commented 4 years ago

有啊。用原来没改的代码还是可以用的 https://drive.google.com/file/d/1MHpslKya-0UCat2Dexou_qZZjqo6qf_o/view?usp=sharing

留个邮箱,我给你看下吧。。。

yangkghjh commented 3 years ago

在群晖上运行,脚本首行可以输出正确的 ipv6 地址,但之后却会报如下错误

xxxx:3a1:xxxx:5060::xxxx

开始处理: RR:xxx DomainName:xxx.xx
Traceback (most recent call last):
  File "/volume3/C/projects/nastools/aliddns2.py", line 318, in <module>
    print("本机IP: " + ip)
TypeError: Can't convert 'NoneType' object to str implicitly
yangkghjh commented 3 years ago

re.search 会使得 ipv6 地址变成 none,绕过就可以设置成功

def get_Local_ipv6_address_win():
    """
        Get local ipv6
    """
    # pageURL = 'https://ip.zxinc.org/ipquery/'
    # pageURL = 'https://ip.sb/'
    pageURL = 'https://api-ipv6.ip.sb/ip'
    content = urllib.request.urlopen(pageURL).read()
    webContent = content.decode("utf8")

    print(webContent)
    ipv6_pattern = '(([a-f0-9]{1,4}:){7}[a-f0-9]{1,4})'

    m = re.search(ipv6_pattern, webContent)

    if webContent is not None:
        return webContent
    else:
        return None
szy0syz commented 3 years ago

TypeError: Can't convert 'NoneType' object to str implicitly 昨晚也是报这个错,命令行少了参数

今天用这个版本设置成功了

author: TreviD

date: 2020-02-21

version: v0.2