您当前的位置: 首页 >  linux

liaowenxiong

暂无认证

  • 0浏览

    0关注

    1171博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

liaowenxiong 发布时间:2020-07-30 13:45:01 ,浏览量:0

文章目录
  • 查询本机外网 IP 地址
  • 查询本机内网 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  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
        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  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        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  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
        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 的,说明目前只有这个口已经插上网线在使用,而其它的并没有在用

关注
打赏
1661566967
查看更多评论
立即登录/注册

微信扫码登录

0.3315s