{"id":1723,"date":"2016-04-25T01:31:06","date_gmt":"2016-04-25T09:31:06","guid":{"rendered":"http:\/\/systemsolver.com\/StatlerBlog\/?p=1723"},"modified":"2016-04-25T01:31:06","modified_gmt":"2016-04-25T09:31:06","slug":"linux-script-and-cron-to-monitor-ip-address","status":"publish","type":"post","link":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/2016\/04\/25\/linux-script-and-cron-to-monitor-ip-address\/","title":{"rendered":"Linux script and cron to monitor ip address"},"content":{"rendered":"<p>I want:<\/p>\n<p><strong>Neorouter server to change ip address if primary server cannot connect to the internet<\/strong><\/p>\n<p>Two alternate ip locations checking for neorouter server primary server<\/p>\n<p>First alternate ip (prim_ip)<\/p>\n<p>ping primary neorouter server for active ip<br \/>\nif up do nothing<br \/>\nif down update<a href=\"https:\/\/www.duckdns.org\/install.jsp\"> duckdns.org <\/a>with prim_ip<br \/>\ncontinue ping primary neorouter server ip<br \/>\nif comes back up then update duckdns.org with primary neorouter server ip<br \/>\ncontinue ping<\/p>\n<p>Second alternate ip (sec_ip)<br \/>\nchecks prim_ip and checks primary neorouter server ip<br \/>\nif both down then second sec_ip updates duckdns.org to itself<br \/>\nif either of the others come back they will update duckdns.org<\/p>\n<p><strong>linux neorouter client<\/strong><br \/>\nif ping google.com but not duckdns.org<br \/>\nthen try to restart neorouter<br \/>\nrun as cron job<\/p>\n<p><strong>cron job<\/strong><\/p>\n<p><a href=\"https:\/\/www.pantz.org\/software\/cron\/croninfo.html\">https:\/\/www.pantz.org\/software\/cron\/croninfo.html<\/a><\/p>\n<p><a href=\"http:\/\/alvinalexander.com\/linux\/unix-linux-crontab-every-minute-hour-day-syntax\">http:\/\/alvinalexander.com\/linux\/unix-linux-crontab-every-minute-hour-day-syntax<\/a><\/p>\n<p><strong>ping script<\/strong><\/p>\n<p><a href=\"http:\/\/www.cyberciti.biz\/tips\/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html\">http:\/\/www.cyberciti.biz\/tips\/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html<\/a><\/p>\n<p>in the comments<\/p>\n<pre><strong>if [[ $(ping -q -c 3 10.1.1.1) == @(*100% packet loss*) ]]; then\n echo \u201c$host is down\u201d\n else\n echo \u201c$host is alive\u201d\n fi<\/strong><\/pre>\n<p>also<\/p>\n<pre><strong>ping -qnc 2 google.com &gt; \/dev\/null 2&gt;&amp;1 &amp;&amp; echo \u2018Host up!\u2019 || echo \u2018Host down!\u2019<\/strong><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I want: Neorouter server to change ip address if primary server cannot connect to the internet Two alternate ip locations checking for neorouter server primary server First alternate ip (prim_ip) ping primary neorouter server for active ip if up do nothing if down update duckdns.org with prim_ip continue ping primary neorouter server ip if comes [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1723","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1723","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/comments?post=1723"}],"version-history":[{"count":0,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/posts\/1723\/revisions"}],"wp:attachment":[{"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/media?parent=1723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/categories?post=1723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systemsolver.goodhealthyday.com\/StatlerBlog\/wp-json\/wp\/v2\/tags?post=1723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}