在windows下通过脚本动态域名DDNS更新
这里采用PowerShell编写脚本请求3322的动态域名接口
$pair = "root:更新密码" $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) $basicAuthValue = "Basic $encodedCreds" $Headers = @{Authorization = $basicAuthValue} Invoke-WebRequest -Headers $Headers -Uri 'http://www.3322.org/dyndns/update?system=dyndns&hostname=oymd.f3322.net'
通过以上脚本即可更新你的动态域名了
下面写成一条命令更新动态IP
Invoke-WebRequest -Headers @{Authorization = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("root:密码"))} -Uri 'http://www.3322.org/dyndns/update?system=dyndns&hostname=oymd.f3322.net'
上面这个只能在Powershell里执行
下面的可以在cmd中执行
PowerShell -Command "(Invoke-WebRequest -Headers @{Authorization = 'Basic '+[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes('root:密码'))} -Uri 'http://www.3322.org/dyndns/update?system=dyndns&hostname=oymd.f3322.net').Content"
如果需要在计划任务里使用
cmd /c PowerShell -Command "(Invoke-WebRequest -UseBasicParsing -Headers @{Authorization = 'Basic '+[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes('root:密码'))} -Uri 'http://www.3322.org/dyndns/update?system=dyndns&hostname=oymd.f3322.net').Content">/ddns.log
本文来自博客园,作者:项希盛,转载请注明原文链接:https://www.cnblogs.com/xiangxisheng/p/16837853.html
浙公网安备 33010602011771号