专题推荐
专题推荐

Linux常用命令:ip addr与ifconfig查看VPS服务器内网ip地址

2020-04-05 11:12 分类:Linux常用命令 阅读(次阅读) 标签:,,

今天帮朋友管理将VPS添加到云锁的时候,发现云锁的服务器列表一直没有添加成功,找了半天才发现,云锁的IP地址显示的是内网IP地址.这个问题应该是阿里云,腾讯云等大厂才会遇到.

于是我来详细说说Linux下面查看服务器的内网与外网ip地址.

先说说Linux ip addr命令:

在 Linux 中,用于显示和配置网络接口的标准命令是 ip ,要显示所有网络接口和相关 IP 地址的列表,请键入ip addr命令.

[root@vpsyi ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65556 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:19:6e:05:d6:28 brd ff:ff:ff:ff:ff:ff
    inet 175.19.49.46/18 brd 175.19.63.255 scope global dynamic eth0
       valid_lft 315184551sec preferred_lft 315184551sec

Linux hostname -I命令:

输入hostname -I命令会直接输出VPS服务器内网ip地址.

[root@VPSYI ~]# hostname -I
175.19.49.48

Linux ifconfig命令:

ifconfig命令也是显示VPS服务器的内部 IP 地址.

[root@vpsyi ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 175.19.49.48  netmask 255.255.192.0  broadcast 175.19.63.255
        ether 00:19:6e:06:d9:24  txqueuelen 1000  (Ethernet)
        RX packets 1562432  bytes 214437145 (204.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1537642  bytes 1358514289 (1.2 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
        loop  txqueuelen 1  (Local Loopback)
        RX packets 12017746  bytes 11222325931 (10.4 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12017746  bytes 11222325931 (10.4 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 


本文地址: https://www.vpsyi.com/linux-ifconfig.html