Linux命令终端如何查询本机的内外网IP地址

查询本机外网 IP 地址

[root@htlwk0001host ~]# curl ifconfig.me # 太慢了,不行

[root@htlwk0001host ~]# curl icanhazip.com
47.114.59.104

[root@htlwk0001host ~]# curl ident.me # 太慢了,不行

[root@htlwk0001host ~]# curl whatismyip.akamai.com
47.114.59.224[root@htlwk0001host ~]# 

[root@htlwk0001host ~]# curl tnx.nl/ip # 不行
127.0.0.1
--- after 12 years of service, tnx.nl/ip is no more. ---

[root@htlwk0001host ~]# curl myip.dnsomatic.com
47.114.59.224[root@htlwk0001host ~]# 

[root@htlwk0001host ~]# curl myip.ipip.net
当前 IP:47.114.59.104  来自于:中国 浙江 杭州  阿里云/电信/联通/移动/教育网

[root@htlwk0001host ~]# curl http://members.3322.org/dyndns/getip
47.114.59.104

查询本机内网 IP 地址

[root@htlwk0001host ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.116.91  netmask 255.255.240.0  broadcast 172.19.127.255
        inet6 fe80::216:3eff:fe15:b7f3  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:15:b7:f3  txqueuelen 1000  (Ethernet)
        RX packets 39472104  bytes 15521220904 (14.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 38258459  bytes 15199147861 (14.1 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 17170519  bytes 9777458856 (9.1 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17170519  bytes 9777458856 (9.1 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
[root@htlwk0001host ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.116.91  netmask 255.255.240.0  broadcast 172.19.127.255
        inet6 fe80::216:3eff:fe15:b7f3  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:15:b7:f3  txqueuelen 1000  (Ethernet)
        RX packets 39472688  bytes 15521320121 (14.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 38259098  bytes 15199345538 (14.1 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

说明:

  1. eth0:是指第一个物理网卡,具体叫光纤以太网接口卡,学名 Fiber Ethernet Adapter0。物理网卡这里指的是服务器上实际的网络接口设备,这里我服务器上双网卡,在系统中看到多个物理网卡则分别对应 eth0、eth1、eth2…,类似 Windows 装了好几个网卡,会显示本地连接1、本地连接2、本地连接3…

  2. lo:localhost,127.0.0.1

  3. en0:en0 是逻辑上的网络接口名,enx(x是一个数字,代表第几块网卡)是标准以太网接口,ent0 是物理设备,en0 是逻辑设备。查看网络接口信息时,假设看到三个网络接口,en0, en1, en2,但是只有 en1 的状态是 Available 的,说明目前只有这个口已经插上网线在使用,而其它的并没有在用

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值