ifconfig是一个实用的工具,主要用于诊断和解决网络问题,以及进行网络配置。
直接使用ifconfig
[root@localhost ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.71.130 netmask 255.255.255.0 broadcast 192.168.71.255
inet6 fe80::20c:29ff:fef0:c1c prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:f0:0c:1c txqueuelen 1000 (Ethernet)
RX packets 286 bytes 24177 (23.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 183 bytes 16848 (16.4 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 2208 bytes 243696 (237.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2208 bytes 243696 (237.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
开启网卡
ifconfig ens160 up
关闭网卡
ifconfig ens160 down
单独查看一块网卡的信息
[root@localhost ~]# ifconfig ens160
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.71.56 netmask 255.255.255.0 broadcast 192.168.71.255
inet6 fe80::20c:29ff:fef0:c1c prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:f0:0c:1c txqueuelen 1000 (Ethernet)
RX packets 133 bytes 13716 (13.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 137 bytes 16437 (16.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- 接口名称:ens160
- 标志:UP(启用)、BROADCAST(广播)、RUNNING(运行中)、MULTICAST(多播)
- MTU:1500字节
- IPv4地址:192.168.71.56
- 子网掩码:255.255.255.0
- 广播地址:192.168.71.255
- IPv6地址:fe80::20c:29ff:fef0:c1c
- IPv6前缀长度:64
- MAC地址:00:0c:29:f0:0c:1c
- 发送队列长度:1000
- 接收数据包:133个,总字节数:13716字节(13.3 KiB)
- 接收错误:0个,丢弃:0个,过载:0个,帧错误:0个
- 发送数据包:137个,总字节数:16437字节(16.0 KiB)
- 发送错误:0个,丢弃:0个,过载:0个,载波错误:0个,冲突:0个