主机参考: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;
这几篇文章你可能也喜欢:
- 马来西亚Casbay Server,AS132841,本机计算机房仅$ 11.59,支持流媒体,例如Tiktok/Unlock GPT
- 如何平衡KAFKA配置中的吞吐量和延迟
- NGINX日志的数据库查询优化(NGINX日志视图)
- 如何监视和配置Linux Monit
- 如果Windows无法在双系统上启动(如果Windows无法在双重系统上启动,为什么不能启动第二个系统?)
本文由主机参考刊发,转载请注明:linux如何读取公网(linux命令行如何查看公网ip) https://zhujicankao.com/120393.html
评论前必须登录!
注册