{"id":275,"date":"2023-02-24T06:31:54","date_gmt":"2023-02-23T22:31:54","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=275"},"modified":"2023-04-30T15:15:59","modified_gmt":"2023-04-30T07:15:59","slug":"shell-script-obtain-native-ip-and-assign-ip-value-to-variable-to-be-used","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/24\/shell-script-obtain-native-ip-and-assign-ip-value-to-variable-to-be-used\/","title":{"rendered":"Shell\u811a\u672c\u83b7\u53d6\u672c\u673aIP\u5e76\u5c06IP\u8d4b\u503c\u7ed9\u53d8\u91cf\u5f85\u7528"},"content":{"rendered":"<h3>\u65b9\u6cd5\u4e00<\/h3>\n<pre><code class=\"language-bash\">#!\/bin\/bash\nETH=&quot;eth0&quot;\nHOST_IP=$(ifconfig $ETH | grep &quot;inet&quot; | awk &#039;{ print $2}&#039; | awk -F: &#039;{print $2}&#039;)\necho $HOST_IP<\/code><\/pre>\n<p><!-- more --><\/p>\n<blockquote>\n<p>\u6ce8\uff1a\u8be5\u65b9\u6cd5\u4f1a\u5c06ipv6\u5730\u5740\u4e00\u5e76\u83b7\u53d6<\/p>\n<\/blockquote>\n<h3>\u65b9\u6cd5\u4e8c<\/h3>\n<pre><code class=\"language-bash\">#!\/bin\/bash\nHOST_IP=$(ifconfig eth0 | grep &quot;netmask&quot; | awk &#039;{ print $2 }&#039;)\necho $HOST_IP<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6cd5\u4e00 #!\/bin\/bash ETH=&quot;eth0&quot; HOST_IP=$(ifconfig [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[89],"class_list":["post-275","post","type-post","status-publish","format-standard","hentry","category-devops-base","tag-shell"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=275"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/275\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}