hi,欢迎访问本站!
当前位置: 首页操作系统正文

linux系统查看IP的命令是什么

墨初 操作系统 366阅读

在linux系统中,如果在没有安装图形界面的情况下查看本地的IP信息是需要使用ssh命令的,下面73so博客就说说在linux系统中使用ssh命令来查看本地IP地址的方法。

linux查看本机IP地址的方法

在linux系统中可以使用下面的命令来查看本机的IP信息

ifconfig -a

例:

[root@VM-16-2-centos ~]# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 101.0.16.2  netmask 255.255.252.0  broadcast 10.06.19.255
        inet6 fe80::5065:ff:fe86:1c3e  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:86:1c:3e  txqueuelen 1000  (Ethernet)
        RX packets 180739870  bytes 32038251651 (29.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 179462128  bytes 32270236620 (30.0 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 13125  bytes 1585429 (1.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13125  bytes 1585429 (1.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

注意:输出结果中的inet 则为当前主机的IP地址

ifconfig命令工具

如果你的系统中无法使用ifconfig命令,可以通过下面的命令进行安装

centos中的安装代码:

yum -y install net-tools

例:

[root@VM-16-2-centos ~]# yum -y install net-tools
已加载插件:fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile

查看ifconfig版本号

[root@VM-16-2-centos ~]# ifconfig -V
net-tools 2.10-alpha

启用/关闭网卡

ifconfig eth0 up   # 启动网卡eth0
ifconfig eth0 down   # 关闭网卡eth0

显示网卡信息 

[root@VM-16-2-centos ~]# ifconfig eth0 #单独显示eth0网卡信息
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 101.0.16.2  netmask 255.255.252.0  broadcast 10.06.19.255
        inet6 fe80::5065:ff:fe86:1c3e  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:86:1c:3e  txqueuelen 1000  (Ethernet)
        RX packets 180756415  bytes 32048131066 (29.8 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 179476989  bytes 32273313924 (30.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

以上就是linux系统中ifconfig的使用命令,当然此命令除了上面所说的几个查询方法外,还可以新增网卡IP地址,修改MAC地址以及删除IP地址等功能,各位可以搜索一下。

声明:无特别说明,转载请标明本文来源!
相关推荐