{"id":91,"date":"2022-11-27T15:25:52","date_gmt":"2022-11-27T07:25:52","guid":{"rendered":"https:\/\/namo.one\/?p=91"},"modified":"2022-11-30T09:36:40","modified_gmt":"2022-11-30T01:36:40","slug":"%e8%8e%b7%e5%8f%96%e5%85%ac%e7%bd%91%e5%9c%b0%e5%9d%80%e5%b9%b6%e6%8f%90%e5%8f%96ip%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/byso.top\/?p=91","title":{"rendered":"\u83b7\u53d6\u516c\u7f51\u5730\u5740\u5e76\u63d0\u53d6ip\u5b57\u7b26\u4e32"},"content":{"rendered":"\n<p>\u83b7\u53d6\u516c\u7f51\u5730\u5740<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl myip.ipip.net &gt; ip.log<\/code><\/pre>\n\n\n\n<p>\u7528sed\u547d\u4ee4\u5220\u9664\u6240\u6709\u4e2d\u6587\u548cip\u5b57\u7b26\u4e32\u524d\u7684\u591a\u4f59\u6587\u672c\u5185\u5bb9\uff0c\u4ee5\u53ca\u884c\u5c3e\u7a7a\u683c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat ip.log | LANG=C sed -r \"s\/&#91;\\x81-\\xFE]&#91;\\x40-\\xFE]\/\/g;s\/ IP\/\/;s\/ *$\/\/\"<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n#allow a dyndns name\n\nHOSTNAME=hostname\nLOGFILE=\/root\/ip.log\n\nCurrent_IP=$(host $HOSTNAME | cut -f4 -d' ')\n\nif &#91; $LOGFILE = \"\" ] ; then\n  ufw insert 1 allow from \"Current_IP\"\n  echo $Current_IP &gt; $LOGFILE\nelse\n\n  Old_IP=$(cat $LOGFILE)\n\n  if &#91; \"$Current_IP\" = \"$Old_IP\" ] ; then\n    echo IP address has not changed\n  else\n    ufw --force delete allow from $Old_IP\n    ufw insert 1 allow from $Current_IP\n    echo $Current_IP &gt; $LOGFILE\n    echo ufw have been updated\n  fi\nfi\n<\/code><\/pre>\n\n\n\n<p>\u7f16\u8f91\u5efa\u7acb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u83b7\u53d6\u516c\u7f51\u5730\u5740 \u7528sed\u547d\u4ee4\u5220\u9664\u6240\u6709\u4e2d\u6587\u548cip\u5b57\u7b26\u4e32\u524d\u7684\u591a\u4f59\u6587\u672c\u5185\u5bb9\uff0c\u4ee5\u53ca\u884c\u5c3e\u7a7a\u683c \u7f16\u8f91\u5efa\u7acb<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-91","post","type-post","status-publish","format-standard","hentry","category-linux-applications"],"_links":{"self":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/91","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=91"}],"version-history":[{"count":2,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/byso.top\/index.php?rest_route=\/wp\/v2\/posts\/91\/revisions\/128"}],"wp:attachment":[{"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byso.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}