ifconfig命令操作网卡

本文介绍了如何在操作系统中安装ifconfig命令,并详细讲解了如何使用它来查看和临时设置网卡的IP信息。通过ifconfig,可以方便地查看网卡状态,选择特定网卡进行IP配置,但需要注意这些配置在服务重启后会丢失。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装ifconfig命令

若系统提示未安装ifconfig软件,可通过以下命令安装:

yum -y install net-tools

查看网卡信息

[root@machine01 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::50c6:fa9f:d76c:2789  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:88:48:82  txqueuelen 1000  (Ethernet)
        RX packets 594  bytes 357220 (348.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 403  bytes 62418 (60.9 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 2592 (2.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 2592 (2.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

查看指定网卡

[root@machine01 ~]# ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::50c6:fa9f:d76c:2789  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:88:48:82  txqueuelen 1000  (Ethernet)
        RX packets 628  bytes 359860 (351.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 428  bytes 65296 (63.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

临时设置IP

[root@machine01 ~]# ifconfig ens33 10.0.0.10 netmask 255.255.255.0

这是临时修改,当重启服务systemctl restart network时,临时IP失效。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值