Last active
August 5, 2022 19:31
-
-
Save dsta50/0d07d04957b0ee5dff11df32d8f31220 to your computer and use it in GitHub Desktop.
[Lua] YAMAHAルータでDDNS (MyDNSJP)にグルーバルIPアドレスを通知する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This Lua script is tells DDNS (MyDNSJP) the global IP address on the YAMAHA RTX router | |
-- Value | |
ddnsid = "userid" | |
ddnspass = "password" | |
ddnsurl = "https://www.mydns.jp/directip.html" | |
gipv4url = "https://inet-ip.info/ip" | |
msg_prefix = "[DDNS] rtx_update_myddnsjp.lua " | |
-- Get Globle IP address info | |
req_gipv4 = { | |
url = gipv4url, | |
method = "GET" | |
} | |
rsp_gipv4 = rt.httprequest(req_gipv4) | |
if rsp_gipv4.code ~= 200 then | |
msg_sufix = "(Error) Failed to get global IP address info: " ..gipv4url | |
rt.syslog("info", msg_prefix..msg_sufix) | |
return | |
end | |
-- Update IP address to DDNS | |
update_ddnsurl = ddnsurl.."?MID="..ddnsid.."\&PWD="..ddnspass.."\&IPV4ADDR="..rsp_gipv4.body | |
req_update_ddns = { | |
url = update_ddnsurl, | |
method = "GET" | |
} | |
rsp_update_ddns = rt.httprequest(req_update_ddns) | |
-- NOTE:May be necessary to change the conditional expression | |
if string.match(rsp_update_ddns.body,"Login.and.IP.address.notify.OK\.") then | |
msg_sufix = "(Info) Successful upload global IP address to DDNS" | |
rt.syslog("info", msg_prefix..msg_sufix) | |
else | |
msg_sufix = "(Error) Failed to upload global IP address to DDNS" | |
rt.syslog("info", msg_prefix..msg_sufix) | |
end | |
return |
Author
dsta50
commented
Aug 5, 2022
- YAMAHA RTX830 (Lua5.1系実装)で実行実施済み
- DDNSの通知結果をHTTPステータスコードで判断不可だったので、HTTP body内の文字列で判断 (33行目)
- DDNS通知後の条件式を変更、以前の文字列だと不十分のため
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment