Linux ifconfig命令
更多资料下载,冲击月薪过万,一线经验工程师录制,
干货满满的嵌入式视频教程,请点击淘宝店:wanglitao.taobao.com
Linux ifconfig命令用来查看和配置网络设备。
ifconfig [-v] [-a] [-s] [interface]
ifconfig命令常用的参数如下:
参数 | 参数说明 |
---|---|
-a | 查看全部网络接口配置信息 |
-s | 显示简短摘要信息(类似 netstat -i) |
-v | 有错误时打印详细出错信息 |
查看当前主机的网络接口信息:
# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.230.149 netmask 255.255.255.0 broadcast 192.168.230.255
inet6 fe80::20c:29ff:fed0:7b22 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:d0:7b:22 txqueuelen 1000 (Ethernet)
RX packets 9169 bytes 1245550 (1.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 476 bytes 46975 (46.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:0c:29:d0:7b:22 txqueuelen 1000 (Ethernet)
RX packets 9682 bytes 1442242 (1.4 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 477 bytes 48652 (48.6 KB)
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 222 bytes 16357 (16.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 222 bytes 16357 (16.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
激活/关闭指定的网卡:
# ifconfig ens33 up
# ifconfig ens33 down
为指定的网卡配置IP地址:
# ifconfig ens33 192.168.230.149
# ifconfig ens33 192.168.230.149 netmask 255.255.255.0
# ifconfig ens33 192.168.230.149 netmask 255.255.255.0
broadcast 192.168.230.1
修改网卡的MAC地址:
# ifconfig ens33 down
# ifconfig ens33 hw ether 00:11:22:33:44:55
# ifconfig ens33 up
《Linux三剑客》视频教程,从零开始快速掌握Linux开发常用的工具:Git、Makefile、vim、autotools、debug,免费赠送C语言视频教程,C语言项目实战:学生成绩管理系统。详情请点击淘宝链接:Linux三剑客