• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

Linux中显示ip地址的命令【显哥出品,必为精品】

运维基础 lixian 5年前 (2019-11-28) 21144次浏览 2个评论 扫描二维码
文章目录[隐藏]

在Linux中有三种查看ip地址的方法,下面我分别来介绍

1.ip address命令

使用ip address命令可以查看具体是ip信息

[root@lixian ~]#ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:8b:2e:bb brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::345d:38a5:8df5:e4e9/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@lixian ~]#

ip adderss可以简写成 ip a

查看具体的指定网卡详细信息

[root@lixian ~]#ip address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:8b:2e:bb brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::345d:38a5:8df5:e4e9/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@lixian ~]#

ip address show eth0可以简写成ip a s eth0

2.ifconfig命令

使用ifconfig需要yum安装net-tools软件

[root@lixian ~]#yum -y install bash-completion
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cn99.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
base                                                        | 3.6 kB  00:00:00     
extras                                                      | 2.9 kB  00:00:00     
updates                                                     | 2.9 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package bash-completion.noarch 1:2.1-6.el7 will be installed
..................此处省略部分输出内容.....................
Transaction test succeeded
Running transaction
  Installing : 1:bash-completion-2.1-6.el7.noarch                              1/1 
  Verifying  : 1:bash-completion-2.1-6.el7.noarch                              1/1 

Installed:
  bash-completion.noarch 1:2.1-6.el7                                               

Complete!

ifconfig eth0 可以指定某个网卡查看详细信息

[root@lixian ~]#ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.100  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::345d:38a5:8df5:e4e9  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:8b:2e:bb  txqueuelen 1000  (Ethernet)
        RX packets 485  bytes 43391 (42.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 294  bytes 35220 (34.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@lixian ~]#

3.hostname命令

hostname -i -I
-i 显示是IPV6和IPV4的信息
-I 只显示ip地址

[root@lixian ~]#hostname -i
fe80::345d:38a5:8df5:e4e9%eth0 10.0.0.100
[root@lixian ~]#hostname -I
10.0.0.100 
[root@lixian ~]#

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:Linux中显示ip地址的命令【显哥出品,必为精品】
喜欢 (10)

您必须 登录 才能发表评论!

(2)个小伙伴在吐槽
  1. 很不错 很棒 加油
    匿名2019-11-28 21:45