Help us understand the problem. What is going on with this article?

RTX1200と0simで冗長構成を組む話

More than 3 years have passed since last update.

とりあえず0simで通信できるように

今回の機材

ルーター:RTX1200
USBLTEモデム:LG L-02C
sim:so-net 0SIM(標準sim)

とりあえずGUIで設定

固定費0円!0 SIMとYAMAHA RTX1200で回線冗長化してみる
を参考に色々設定

とりあえずLANケーブルを引っこ抜いて設定がうまく行ってるか確認

2016/11/08 09:46:57: LAN2: link down
2016/11/08 09:47:47: PP[02] IP Commencing: UDP 192.168.0.1:51333 > 111.221.77.169:40014
2016/11/08 09:47:47: PP[02] Calling so-net.jp with usb1
2016/11/08 09:47:47: USB[1] SEND [ATD*99***1#]
2016/11/08 09:47:47: USB[1] RECV [CONNECT]
2016/11/08 09:47:47: USB[1] Connected
2016/11/08 09:47:48: PP[02] PPP/IPCP up  (Local: 100.66.251.104, Remote: None)
2016/11/08 09:48:47: LAN2: link up (1000BASE-T Full Duplex)
2016/11/08 09:50:58: PP[02] Disconnecting, cause [Data transaction timer (SEND) expired]
2016/11/08 09:50:58: USB[1] SEND SIGNAL [DTR=OFF]
2016/11/08 09:50:58: USB[1] RECV [NO CARRIER]
2016/11/08 09:51:02: PP[02] Disconnected, cause [Data transaction timer (SEND) expired]
2016/11/08 09:51:02: [MOBILE] Signal Strength (0-5): 5 [|||] (usb1)

問題なさそうですね、回線を戻すと勝手に切れてくれます

追加の設定

さーて、月1でリミットをリセットしないといけないのと3ヶ月通信がないと勝手に解約されるのでそれ用にluaを書きます

monthly_kirikae.lua
--------------------------##  設定値  ##--------------------------------
-- メールの設定
mail_tbl = {                -- ★
    smtp_address = "example.com,
    smtp_auth_name = "hoge",
    smtp_auth_password = "hogehoge",
    smtp_auth_protocol = "適切に",
    from = "hoge@example.com",
    to = "hogehoge@example.jp",
}

-- メールの送信に失敗した時に出力する SYSLOG のレベル(info, debug, notice)
log_level = "お好きに"      -- ★

----------------------##  設定値ここまで  ##----------------------------
-- 現在の日時を取得する関数                               --
------------------------------------------------------------
function time_stamp()
    local t

    t = os.date("*t")
    return string.format("%d/%02d/%02d %02d:%02d:%02d", 
        t.year, t.month, t.day, t.hour, t.min, t.sec)
end

------------------------------------------------------------

----------------------## メインルーチン ## ----------------------------

str, rtn = rt.command("lan shutdown lan2") --メイン回線がつながってるI/Fをshutdown
while (loss ~= 0) do --loss率が0%になるまでうち続ける
   rtn, str = rt.command("ping -c 1 8.8.8.8") --とりあえず1回googleのPublicDNSへ
    if (rtn) and (str) then
        loss = string.match(str, "(%d+)%.%d+%%")      -- パケットロス率(NNN.N%)の整数部を抽出
        if (loss ~= nil) then
            loss = tonumber(loss)
        end
    end
end
rtn, str = rt.command("no lan shutdown lan2") --メイン回線がつながってるI/FをUp
 rtn, str = rt.command("clear mobile access limitation") --モバイル回線の使用量をリセット

---------------------------##メール送信部##----------------------------------------
       mail_tbl.subject = string.format("monthly reset (%s)", time_stamp())
        mail_tbl.text = string.format("マンスリーの通信料リセットが成功しました")
       rtn2 = rt.mail(mail_tbl)
        if (not rtn2) then
            rt.syslog(log_level, "failed to send mail. monthly_kirikae.lua")
        end

あとは設定に毎月させるように書き込んで終わりです

schedule at 1 */1 03:00 * lua monthly_kirikae.lua

終わりに

syslogを監視して切り替わったらメールを送るようなluaを書いたのですが動作しません
ヘルプ!

とりあえず緊急的に繋げられるようになったので良しとします

qunaud
しがないインフラエンジニア見習い
http://qunaud.dip.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした