文章目录
- ifconfig 查看状态
- ifconfig 常用命令
ifconfig是linux中用于显示或配置网络设备(网络接口卡)的命令,英文全称是network interfaces configuring。
ifconfig除了查看网卡状态外,还可以启用或禁用网卡,配置IP掩码,mtu值,修改mac地址,开启或关闭arp协议。
ifconfig 查看状态
Rocky系统输入ifconfig可查看所有网卡的基本信息。
Ubuntu需要先安装网络工具 apt install net-tools
[root@rocky ~]
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.100.200 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::20c:29ff:febc:6464 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:bc:64:64 txqueuelen 1000 (Ethernet)
RX packets 136 bytes 13556 (13.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 137 bytes 14978 (14.6 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 24 bytes 2514 (2.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 24 bytes 2514 (2.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- ens33 表示网卡名称,一般虚拟机为ens33,物理机为eth0。
- lo 表示回环地址,ping 127.0.0.1 就是给自己发送数据包。
名称 | 含义 |
---|
flags 网口状态 | UP:接口已启用 BROADCAST :主机支持广播 RUNNING:接口在工作中 MULTICAST:主机支持多播 |
mtu | 最大传输单元,以字节为单位 |
inet | ipv4地址 |
netmask | 网络掩码 |
broadcast | 广播地址 |
inet6 | ipv6地址 |
ether | 链接方式为以太网,后面为硬件mac地址 |
txqueuelen | 网卡的传送队列长度 |
RX | 接收数据信息 |
TX | 发送数据信息 |
ifconfig 常用命令
ifconfig加上参数ens33便可对该网卡进行配置:
ifconfig ens33 up
ifconfig ens33 down
ifconfig ens33 192.168.100.202
新增一张网卡eth0后,配置IP,掩码,广播地址:
ifconfig eth0 172.16.100.200 netmask 255.255.255.0 broadcast 172.16.100.255
修改网卡的mac地址,需要先关闭后启用:
ifconfig ens33 down
ifconfig ens33 hw ether 00:0c:29:bc:3e:7a
ifconfig ens33 up
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)