ifconfig 命令

ifconfig命令是 Linux 系统配置网卡的命令工具,可用于查看和更改网络接口的地址和参数,包括IP 地址广播地址子网掩码物理地址,也可激活关闭网卡。用法:

$ifconfig 网络接口 [选项] 地址/参数

序号 选项/参数 说明 示例
1 -a 查看系统拥有的全部网络接口 ifconfig -a
2 网络接口 指定操作某个网口 ifconfig eth0 192.168.1.125
3 broadcast 设置网口广播地址 ifconfig eth0 broadcast 192.168.1.255
4 netmask 设置网口子网掩码 ifconfig eth0 netmask 255.255.255.0
5 hw ether 设置网卡物理地址(如果驱动不支持则无效) ifconfig eth0 hw ether 11:22:33:44:55:66
6 up 激活指定网卡 ifconfig eth0 up
7 down 关闭指定网卡 ifconfig eth0 down

说明:

序号 描述
1 使用ifconfig命令操作网口需要root权限
2 使用ifconfig修改网卡配置无需重启系统,但不能复位保存
3 可以同时配置网口的多个参数
使用ifconfig同时配置网卡多个参数的范例:
$ sudo ifconfig eth1 192.168.1.125 netmask 255.255.255.0 broadcast 192.168.1.255 up

你可能感兴趣的:(Linux)