当前位置:   article > 正文

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

电信光猫关闭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 )

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/183913
推荐阅读
相关标签
  

闽ICP备14008679号