beijiaoff

请问 ddns 能否报告一个内网 ip 地址上去。

  •  
  •   beijiaoff · Sep 23, 2022 · 4387 views
    This topic created in 1507 days ago, the information mentioned may be changed or developed.

    场景是需要用域名代替一个局域网的动态 ip 。

    16 replies  •  2022-09-28 22:10:56 +08:00
    Orchestraa
    Orchestraa
    Sep 23, 2022 via iPhone
    1
    局域网内为啥还需要动态 ip 哈哈哈哈
    icySoda
    icySoda
    Sep 23, 2022 via iPhone
    2
    cloudflare 可以
    royzheng
    royzheng
    Sep 23, 2022
    3
    可以
    Dkngit
    Dkngit
    Sep 23, 2022
    4
    自己写程序对接 DNS 服务商的 API ,提交 IP 更新
    AoEiuV020CN
    AoEiuV020CN
    Sep 23, 2022
    5
    能,但都局域网了,静态 ip 或者 dhcp 静态分配不是更香吗,
    lxc404
    lxc404
    Sep 23, 2022
    6
    当然能,我用的 dns.he.net 的服务,结合定时任务每 10 分钟报告一次网卡 ip ,脚本也简单

    ---

    $ddns_domain=""
    $ddns_key=""

    $wlan_ip=(Get-NetIPAddress -InterfaceAlias WLAN -AddressFamily IPv4).IPAddress

    $ddns_url="http://dyn.dns.he.net/nic/update?hostname=$ddns_domain&myip=$wlan_ip"

    $netAssembly = [Reflection.Assembly]::GetAssembly([System.Net.Configuration.SettingsSection])
    if ($netAssembly) {
    $bindingFlags = [Reflection.BindingFlags] "Static,GetProperty,NonPublic";
    $settingsType = $netAssembly.GetType("System.Net.Configuration.SettingsSectionInternal");
    $instance = $settingsType.InvokeMember("Section", $bindingFlags, $null, $null, @());
    if($instance) {
    $bindingFlags = "NonPublic","Instance";
    $useUnsafeHeaderParsingField = $settingsType.GetField("useUnsafeHeaderParsing", $bindingFlags);
    if($useUnsafeHeaderParsingField) {
    $useUnsafeHeaderParsingField.SetValue($instance, $true);
    };
    };
    };

    $pair = "$($ddns_domain):$($ddns_key)"
    $encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Pair))
    $headers = @{ Authorization = "Basic $encodedCredentials" }

    Invoke-WebRequest -Uri $ddns_url -Method Get -Headers $headers
    singerll
    singerll
    Sep 23, 2022
    7
    @xipuxiaoyehua @AoEiuV020CN 很多场景很难固定的,比如物联网卡组成的局域网就没办法固定每张 sim 卡的 ip 。
    Orchestraa
    Orchestraa
    Sep 23, 2022
    8
    @singerll dns 解析的时候地址填什么都无所谓的,dns 服务商都有更新解析记录的 api 接口,直接调用接口就可以了
    neroxps
    neroxps
    Sep 23, 2022
    9
    哈哈,很明显这种需求就是没有局域网权限。
    lixinrui000
    lixinrui000
    Sep 23, 2022
    10
    可以,在内网里面我就这样干,但是注意 dnsmasq 等 DNS 服务器要关闭过滤本地地址功能。
    LnTrx
    LnTrx
    Sep 23, 2022
    11
    DDNS 的本质就是通过 API 更新 DNS 记录。只要能获取到地址、构造 API 请求,自然就不成问题。
    wzdxy
    wzdxy
    Sep 24, 2022
    12
    既然是局域网用 openwrt 直接修改 dns 就行吧
    lsylsy2
    lsylsy2
    Sep 25, 2022 via Android
    13
    注意你家的 dns 服务器需要开启 rfc1918
    Marionic0723
    Marionic0723
    Sep 26, 2022 via Android
    14
    Openwrt 在设置里打开「允许非公网 IP 」即可
    datou
    datou
    Sep 27, 2022
    15
    局域网内直接用 hostname 访问不就行了?

    还折腾啥域名。。。
    Beethoven03
    Beethoven03
    Sep 28, 2022 via iPhone
    16
    城域网可以试试,别的没啥用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   498 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 21:49 · PVG 05:49 · LAX 13:49 · JFK 16:49
    ♥ Do have faith in what you're doing.