Linux命令之ifconfig
1.ifconfig介绍
linux命令ifconfig可以用来查看网卡信息,启停网卡,设置网络IP等,基于实际运维场景,我们就来说说ifconfig普遍的常规用法
2.ifconfig用法
ifconfig [网络设备名称] [参数]
ifconfig参数
参数 说明
up 启动网卡
down 停止网卡
3.实例
3.1.查看网卡信息
命令:
ifconfig
[root@rhel77 ~]# ifconfig
ens33: flags=4163 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
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 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
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 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
————————————————
版权声明:本文为CSDN博主「小黑要上天」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/z19861216/article/details/131673260