Linux命令(56)之ifconfig

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

3.4.启动网卡

命令:

ifconfig ens33 up

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值