当然能,我用的
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