简介
本文介绍Linux的ifconfig命令的用法。
作用
显示或配置网络。
示例
作用 | 命令 |
查看ip地址 | ifconfig |
配置mac地址 | ifconfig eth0 hw ether 11:22:33:44:55:66; //注意:最好配置为电脑的mac。(在电脑mac基础上修改一点点) //配置mac地址需要在配置ip地址之前进行。 |
配置ip地址和子网掩码 | ifconfig eth0 192.168.0.100 netmask 255.255.255.0; |
关闭网络 | ifconfig eth0 down; |
启动网络 | ifconfig eth0 up; |
设备配置示例
iptables -F;ifconfig eth0 hw ether 11:22:33:44:55:66;ifconfig eth0 192.168.1.193 netmask 255.255.255.0;route add default gw 192.168.1.254