您现在的位置:首页 > 帮助中心 > 服务器问题 > 如何查看CentOS Linux上面的IP地址信息(主要针对CentOS 7.x)

如何查看CentOS Linux上面的IP地址信息(主要针对CentOS 7.x)

来源:中国U网 日期:2018-01-19 类别:服务器问题 点击:734
用过Linux的很多都知道查看IP的命令是ifconfig,但是这个在CentOS 7.x默认是不存在的命令,那如何来查看CentOS 7的IP信息呢?

对于CentOS 5.x, 6.x,来说,查看IP信息的命令是ifconfig,这个命令是在系统里面默认就带的,但是自从有了CentOS 7之后,很多人发现这个命令不存在了,执行ipconfig命令之后是这样的。

[root@localhost ~]# ipconfig
-bash: ipconfig: command not found
 
那如何来查看CentOS 7的IP信息呢?  
 
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    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
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp5s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:1b:21:bb:f9:fc brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/29 brd 192.168.1.15 scope global enp5s0f0
       valid_lft forever preferred_lft forever
    inet6 fe80::21b:21ff:febb:f9fc/64 scope link
       valid_lft forever preferred_lft forever
3: enp1s0f0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 00:25:90:35:de:e4 brd ff:ff:ff:ff:ff:ff
4: enp1s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 00:25:90:35:de:e5 brd ff:ff:ff:ff:ff:ff
5: enp5s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000
    link/ether 00:1b:21:bb:f9:fd brd ff:ff:ff:ff:ff:ff
 
在这里,我们看到了5个网络设备,enp5s0f0上面的192.168.1.10/29就是我们的IP地址。
 
另外还可以安装iconfig命令,首先需要知道哪个工具包里面有iconfig命令,如果不知道的话,可以用yum provides ifconfig 来查看,通过此命令知道是net-tools
 
# yum install net-tools
 
安装好之后,我们熟悉的iconfig命令就可以用了
 
# ifconfig
enp1s0f0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:25:90:35:de:e4  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfbbe0000-fbbfffff
 
enp1s0f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:25:90:35:de:e5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfbb60000-fbb7ffff
 
enp5s0f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.248  broadcast 192.168.1.10
        inet6 fe80::21b:21ff:febb:f9fc  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:bb:f9:fc  txqueuelen 1000  (Ethernet)
        RX packets 23465  bytes 25373312 (24.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19151  bytes 3629457 (3.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
enp5s0f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:1b:21:bb:f9:fd  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        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 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 

 


关键词:查看IP信息,CentOS 7.x,ifconfig,ip addr
如何查看CentOS Linux上面的IP地址信息(主要针对CentOS 7.x)为中国U网原创文章,在不经过允许的情况下,禁止用于商业用途或随意转载,转载请注明出处,并加上本页链接地址:
http://www.cuwww.com/help/detail-79.html
版权所有 中国U网 侵权必究 免责声明 互联网不良信息举报
旺旺:点击这里给我发消息
售前:cuwww
售前:cuwww
售后:cuwww
技术:cuwww