Linux命令(56)之ifconfig
  wwLZeziuqjLR 2023年11月02日 26 0

Linux命令之ifconfig

1.ifconfig介绍

linux命令ifconfig可以用来查看网卡信息,启停网卡,设置网络IP等,基于实际运维场景,我们就来说说ifconfig普遍的常规用法

2.ifconfig用法

ifconfig [网络设备名称] [参数]

ifconfig参数

参数

说明

up

启动网卡

down

停止网卡

3.实例

3.1.查看网卡信息

命令:

ifconfig

[root@rhel77 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.169  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::fab1:2705:b2c9:676d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:01:1c:bf  txqueuelen 1000  (Ethernet)
        RX packets 363  bytes 33322 (32.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 247  bytes 24982 (24.3 KiB)
        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 32  bytes 2528 (2.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 2528 (2.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:bf:ab:54  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

[root@rhel77 ~]#

3.2.过滤网卡IP信息

命令:

ifconfig | grep inet | awk '{print $2}' | head -n1

[root@rhel77 ~]# ifconfig | grep inet | awk '{print $2}' | head -n1
192.168.10.169
[root@rhel77 ~]#

3.3.停止网卡

命令:

ifconfig ens33 down

Linux命令(56)之ifconfig_ifconfig

3.4.启动网卡

命令:

ifconfig ens33 up

Linux命令(56)之ifconfig_ifconfig_02



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论