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

本文详细描述了如何通过光猫设置拨号上网获取IPv6地址,以及使用阿里云DDNS服务实现远程设备的动态DNS映射。教程包括了修改光猫设置、配置TP-Link路由器和编写Python脚本来自动化更新DNS记录的过程。

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 )

### 如何获取电信超级密码访问控制台 为了使仅作为桥接设备工作,通常需要获得其超级管理员权限。以下是具体的操作方法: #### 方法一:通过浏览器调试模式获取超级管理员密码 对于大多数电信而言,可以通过以下步骤获取超级管理员账户信息: - 使用电脑直接连接至打开浏览器。 - 输入网址 `http://192.168.1.1:8080/login.html` 登录默认页面[^3]。 - 利用背面标注的标准用户凭证完成初次登录。 - 接着按下键盘上的 F12 键启动开发者工具,在 Sources 或者 Console 面板内执行命令 `http://192.168.1.1:8080/usbbackup.cmd?action=backupeble&sessionKey=${sessionKey}` 来请求备份文件链接。 #### 方法二:利用已知漏洞或特定脚本自动提取 针对某些型号如天翼网关 PT926E 的情况,则可以考虑采用编程手段自动化这一过程。这涉及到了解目标硬件的具体安全机制以及可能存在的弱点。例如,有教程展示了怎样运用 Python 脚本来模拟合法的身份验证流程从而取得更高层次的管理权能[^5]。 需要注意的是,在任何情况下都应该遵循法律法规的要求来进行此类操作;未经授权擅自尝试侵入他人网络设施可能会触犯刑法。 ```python import requests url = "http://192.168.1.1:8080/" payload = {'action': 'backupeble', 'sessionKey': '${sessionKey}'} response = requests.get(url + '/usbbackup.cmd', params=payload) if response.status_code == 200: print('成功获取到配置文件') else: print(f'失败 {response.status_code}') ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值