在 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
到此这篇关于linux服务器上查看内网ip和公网ip的方法小结的文章就介绍到这了,更多相关linux查看内网ip和公网ip内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论