公网IP
[root@AlexWong nginx]# curl ifconfig.me
124.71.18.53
# 如果不行,写全地址
[root@AlexWong nginx]# curl http://www.ifconfig.me
124.71.18.53
124.71.18.53就是外网IP
这个方法同样适用于win10
内网IP
[root@AlexWong nginx]# ifconfig | grep eth0 -A3
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.15 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::f816:3eff:fe4a:a171 prefixlen 64 scopeid 0x20<link>
ether fa:16:3e:4a:a1:71 txqueuelen 1000 (Ethernet)
eth0: 192.168.0.15就是内网地址
windows是 ipconfig

这篇博客介绍了如何在Linux系统中通过命令行获取公网和内网IP地址。公网IP可以通过curl ifconfig.me或curl http://www.ifconfig.me获取,内网IP则使用ifconfig命令并筛选eth0信息来得到。这种方法同样适用于Windows系统的ipconfig命令。

1686

被折叠的 条评论
为什么被折叠?



