ifconfig
(interface configuration)是一个老旧的程序,用于配置和显示Linux系统上网络接口的网络参数。它已经在许多Linux发行版中被ip
命令替代,但仍可以在一些系统上使用。以下是ifconfig
的一些基本使用方法:
-
查看所有接口的当前配置:
ifconfig
-
查看特定接口的配置(例如
eth0
):ifconfig eth0
-
启用或关闭指定网络接口(例如启用
eth0
):ifconfig eth0 up
关闭
eth0
:ifconfig eth0 down
-
配置网络接口的IP地址和子网掩码:
ifconfig eth0 192.168.1.10 netmask 255.255.255.0
-
改变MAC地址:
ifconfig eth0 hw ether 02:01:02:03:04:08
-
添加一个新的IP地址到接口:
ifconfig eth0:0 192.168.1.11
-
查看接口的统计数据:
ifconfig eth0 -a