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

ipv6 地址获取代码 #132

Open
poshizi opened this issue Apr 26, 2023 · 3 comments
Open

ipv6 地址获取代码 #132

poshizi opened this issue Apr 26, 2023 · 3 comments

Comments

@poshizi
Copy link

poshizi commented Apr 26, 2023

使用ipv6ddns时,调用第69行获取的为ipv6地址有可能为内网地址,建议更新,我这一行代码为获取2开通的ipv6地址,国内使用可能更好一点,
ip addr show dev eth0 | sed -e's/^.inet6 (2[^ ])/64 scope global dynamic.*$/\1/;t;d'

@rehiy
Copy link
Owner

rehiy commented May 24, 2023

这个可能性太多了,还是建议走外部接口

@ggtony233
Copy link

#!/usr/bin/python3
import re
import os

def getip():
    lan6="lan6"
    output=os.popen("ip addr|grep inet6").read()
#    print(output)
    result=re.findall(r"(?<=inet6\s)\w.*(?=\/).*dynamic\s",output)
#    print(result)
    for i in range(len(result)):
        finalresult=re.search(r".*(?=\/128)",result[i])
        if finalresult is not None:
            return finalresult.group()
#    finalresult=re.search(r".*(?=\/128)",result.group())
#    print(finalresult.group())

def main():
    print(getip())
if __name__=="__main__":
    main()

我自己用的,有python就行

@ggtony233
Copy link

效果杠杠的

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

No branches or pull requests

3 participants