
博客目录
-
- 查看内网 IP
-
- 方法 1:使用 `ip` 命令(推荐)
- 方法 2:使用 `ifconfig` 命令
- 方法 3:查看特定网卡
- 方法 4:使用 `hostname` 命令
- 查看公网 IP
-
- 方法 1:使用在线服务(服务器需要能访问外网)
- 方法 2:使用 `dig` 命令
- 方法 3:使用 `nslookup`
在 Linux 服务器上查看内网 IP 和公网 IP 的方法如下:
查看内网 IP
方法 1:使用 ip 命令(推荐)
ip addr show
# 或简写
ip a
方法 2:使用 ifconfig 命令
ifconfig
# 如果命令不存在,可能需要安装:sudo apt install net-tools (Ubuntu/Debian)
方法 3:查看特定网卡
# 查看eth0网卡
ip addr show eth0
# 查看ens33网卡
ip addr show ens33
方法 4:使用 hostname 命令
hostname -I

查看公网 IP
方法 1:使用在线服务(服务器需要能访问外网)
# 使用curl
curl ifconfig.me
curl icanhazip.com
curl ipinfo.io/ip
curl api.ipify.org
# 使用wget
wget -qO- ifconfig.me
方法 2:使用 dig 命令
# 查看DNS解析到的公网IP
dig +short myip.opendns.com @resolver1.opendns.com
方法 3:使用 nslookup
nslookup myip.opendns.com resolver1.opendns.com
觉得有用的话点个赞 👍🏻 呗。 ❤️❤️❤️本人水平有限,如有纰漏,欢迎各位大佬评论批评指正!😄😄😄
💘💘💘如果觉得这篇文对你有帮助的话,也请给个点赞、收藏下吧,非常感谢!👍 👍 👍
🔥🔥🔥Stay Hungry Stay Foolish 道阻且长,行则将至,让我们一起加油吧!🌙🌙🌙

网硕互联帮助中心





评论前必须登录!
注册