| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |

在Linux下讀取公網IP地址
要獲取Linux計算機的公共IP地址,可以使用以下方法:
使用卷曲命令:
& ltcode class = & quot殼牌& quot& gtcurl ifconfig.me & lt/code & gt;使用wget命令:
& ltcode class = & quot殼牌& quot& gtwget-qO-https://ifconfig . me & lt;/code & gt;使用dig命令:
& ltcode class = & quot殼牌& quot& gtdig+short myip.opendns.com @ resolver 1 . opendns . com & lt;/code & gt;使用ipify命令:
& ltcode class = & quot殼牌& quot& gtipify & lt/code & gt;將結果保存在變量中:
要將獲得的公共IP地址保存在變量中,可以使用以下語法:
& ltcode class = & quot殼牌& quot& gtpublic _ IP = $(curl ifconfig . me)& lt;/code & gt;示例:
獲取公共IP地址并將其打印到終端:
& ltcode class = & quot殼牌& quot& gtcurl ifconfig.me & lt/code & gt;獲取公共網絡的IP地址,并將其保存在變量中:
& ltcode class = & quot殼牌& quot& gtpublic _ IP = $(curl ifconfig . me)echo $ public _ IP & lt;/code & gt;
這幾篇文章你可能也喜歡:
- 如何在坡道環境中優化數據庫(數據庫優化方法)
- 如何解決動物園管理器延遲問題
- 如何備份和恢復Zookeeper數據(Zookeeper數據所在)
- 如何優化Zookeeper內存使用率(Zookeeper Zuul)
- 如何管理數據庫偵聽器(數據庫Binlog偵聽器)
本文由主機參考刊發,轉載請注明:linux如何讀取公網(linux命令行如何查看公網ip) http://m.k2270.com/120393.html
主機參考

















評論前必須登錄!
注冊