浙江电信光猫获取IPV6并关闭防火墙

1 首先查看光猫背面的密码,记下来
2 (可选)打电话给10000改成桥接,理由是装摄像头外网访问,然后记录下来拨号账号(实测可以Wifi路由器加电脑多拨,自己配置拨号上网)
在这里插入图片描述
在这里插入图片描述

3 连上网线,访问192.168.1.1:8080,用户名useradmin,密码是光猫背面的密码,去安全-防火墙-启用IPV6 SESSION下面去掉钩子后保存
在这里插入图片描述
4 访问http://192.168.0.1/,去TP-Link里面关闭IPv6防火墙,打开DMZ主机
在这里插入图片描述
在这里插入图片描述
这样子做完后,电脑直接连光猫拨号就能获取IPv6地址,用于SunShine串流,配合阿里云DDNS进行远程桌面,实测IPv6地址比较稳定、每次拨号都会换一下,拨号后不断连不会变。
其次,设置为DMZ主机的电脑连上Wifi后,能够使用TP路由器的IPv6地址连接,但是电脑自身的IPv6地址无法Ping通,这个方案不需要改桥接。
附上常用链接
手柄测试:https://www.9slab.com/gamepad/home
本机ip获取 可用于DDNS:https://ident.me/
IPv6地址测试:https://www.test-ipv6.com/index.html.zh_CN
IPv6地址测试:https://test-ipv4.com/
被Ping测试:https://ipw.cn/ipv6ping/

SunShine需要打开设置:UPnP和Address Family
注意如果需要远程映射手柄,必须要安装sunshine-windows-installer.exe,便携版的sunshine-windows-portable.zip无法正确映射手柄
在这里插入图片描述
附上DDNS参考代码

import os, time
# import socket
from aliyunsdkcore.client import AcsClient
from aliyunsdkalidns.request.v20150109.DescribeSubDomainRecordsRequest import DescribeSubDomainRecordsRequest
from aliyunsdkalidns.request.v20150109.DeleteSubDomainRecordsRequest import DeleteSubDomainRecordsRequest
from urllib.request import urlopen
import json
import requests

# pip install aliyun-python-sdk-core-v3 
# pip install aliyun-python-sdk-alidns==3.0.1

class DnsController:
    access_key_id = "***"
    access_key_secret = "***"

    region = "cn-hangzhou" # 时区
    # record_type = "A" # ipv4
    record_type = "AAAA" # ipv6
    domain = "***" # 一级域名
    name_ipv4 = ["***"] # 需要解析的二级域名

    def __init__(self):
        self.client = AcsClient(
            self.access_key_id,
            self.access_key_secret,
            self.region
        )

    # 添加新的域名解析记录
    def add(self, DomainName, RR, Type, Value):
        from aliyunsdkalidns.request.v20150109.AddDomainRecordRequest import AddDomainRecordRequest
        request = AddDomainRecordRequest()
        request.set_accept_format('json')
        request.set_DomainName(DomainName)
        request.set_RR(RR)
        request.set_Type(Type)
        request.set_Value(Value)
        response = self.client.do_action_with_exception(request)
        print("Success update", RR + "." + DomainName, "at", Value, time.strftime(", %Y-%m-%d, %H:%M:%S."))
        print(response)

    # 实现ddns
    def update_target_dns(self, ip_address):
        request = DescribeSubDomainRecordsRequest()
        request.set_accept_format('json')
        request.set_DomainName(self.domain)

        for item in self.name_ipv4:
            request.set_SubDomain(item + '.' + self.domain)
            response = self.client.do_action_with_exception(request)
            domain_list = json.loads(response)

            if domain_list['TotalCount'] == 0:
                self.add(self.domain, item, self.record_type, ip_address)
            else:
                if domain_list['DomainRecords']['Record'][0]['Value'].strip() != ip_address.strip():
                    request = DeleteSubDomainRecordsRequest()
                    request.set_accept_format('json')
                    request.set_DomainName(self.domain)
                    request.set_RR(item)
                    response = self.client.do_action_with_exception(request)
                    print("Delete old DNS.")
                    self.add(self.domain, item, self.record_type, ip_address)
                else:
                    print("DNS exists,", item + '.' + self.domain, "at", ip_address, time.strftime(", %Y-%m-%d, %H:%M:%S."))
#%%
import os
import re


def getIPv6Address():
    output = os.popen("ipconfig /all").read()
    result = re.findall(r"(([a-f0-9]{1,4}:){7}[a-f0-9]{1,4})", output, re.I)
    if len(result)>0 and len(result[0][0])>0:
        res = result[0][0].strip()
    else: 
        print('reconnect')
        result = os.popen("rasdial 宽带连接 *** ***").read()
        if result.find("Command completed successfully")>=0:
            res = getIPv6Address()
    return res

def get_external_ip():
    try:
        ip = requests.get('https://ident.me').text.strip()
        # ip = requests.get('https://v6.ident.me').text.strip()
        return ip
    except:
        return None
#%%
def main():
    root_path = '.'
    log_path = root_path + '/ip_log.log'
    fa = open(log_path, 'a', encoding='utf-8')
    # cur_ip = socket.gethostbyname(socket.gethostname())
    # cur_ip = get_external_ip()
    cur_ip = getIPv6Address()
    if not os.path.isfile(log_path) and fa.read().strip() == '':
        fa.write(cur_ip + '##')
        DnsController().update_target_dns(cur_ip)
        fa.close()
        return 0

    with open(log_path, 'r', encoding='utf-8') as fr:
        old_ip = fr.read().strip('##').split('##')[-1]
        if old_ip != cur_ip or old_ip is None:
            # print('old:', old_ip)
            fa.write(cur_ip + '##')
            DnsController().update_target_dns(cur_ip)

    fa.close()


if __name__ == '__main__':
    # main()
    DDNS = DnsController()
    # while True:
    #     DDNS.update_target_dns(get_external_ip())
    #     time.sleep( 60 * 60 * 6 )
    ip = getIPv6Address()
    DDNS.record_type = "AAAA" if ip.find(':')>0 else "A"
    DDNS.update_target_dns(ip)
    while True:
        try:
            if ip != getIPv6Address():
                ip = getIPv6Address()
                DDNS.record_type = "AAAA" if ip.find(':')>0 else "A"
                print("IP change to", ip)
                DDNS.update_target_dns(ip)
        except Exception as e:
            print(e)
        time.sleep( 1 )
        # time.sleep( 60 * 1 )

  • 10
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在OpenWRT中获取IPv6地址的步骤如下: 1. 首先,确保你的光猫已经设置为桥接模式,并且路由器已经成功进行了PPPoE拨号。 2. 登录到OpenWRT的管理界面。 3. 在管理界面中,找到网络设置或网络接口的选项。 4. 找到WAN口的设置选项,并点击进入。 5. 在WAN口设置中,你应该能够找到IPv6相关的设置选项。 6. 确保IPv6设置中的RA服务和DHCPv6服务都被设置为服务器模式,并且NDP代理已经被禁用。 7. 在IPv6设置中,你可以设置LAN口的IPv6分配长度。一般来说,你可以选择大于60小于等于64的数字,但建议直接使用64。 8. 如果你需要自定义IPv6 DNS服务器,你可以在相应的设置选项中添加你的DNS服务器。 9. 保存并应用你的设置。 通过以上步骤,你应该能够成功获取到OpenWRT路由器的IPv6地址。请注意,具体的界面和选项可能会因为不同的OpenWRT版本而有所不同,所以请根据你的实际情况进行相应的设置。 #### 引用[.reference_title] - *1* [OpenWrt 软路由 IPV6设置](https://blog.csdn.net/mshxuyi/article/details/129340914)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [OpenWRT开启IPv6教程](https://blog.csdn.net/axxxwo/article/details/128759475)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [OpenWrt之IPv6设置详解](https://blog.csdn.net/a924282761/article/details/129067001)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值