ifconfig(interface configuration 的缩写)是一个用于查看和配置网络接口的命令行工具,常见于 Linux / Unix / macOS 系统。
ifconfig 主要用来:
ifconfig
或(更详细)
ifconfig -a
输出示例:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>
inet 192.168.1.100 netmask 255.255.255.0
ether 00:11:22:33:44:55
ifconfig eth0
sudo ifconfig eth0 up
sudo ifconfig eth0 down
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
sudo ifconfig eth0 hw ether 00:11:22:33:44:66
⚠️ ifconfig 已被逐步淘汰
ifconfig 属于 net-tools 包ip 命令| ifconfig | ip 命令 |
|---|---|
ifconfig |
ip addr |
ifconfig eth0 up |
ip link set eth0 up |
ifconfig eth0 192.168.1.100 |
ip addr add 192.168.1.100/24 dev eth0 |
sudo apt install net-tools
sudo yum install net-tools
Windows 没有 ifconfig,对应的是:
ipconfig
(注意是 ipconfig,不是 ifconfig)
ifconfig 是 Linux/Unix 下查看和配置网络接口的传统命令,但现在更推荐使用
ip命令。
如果你愿意,我可以帮你对比 ifconfig 和 ip 命令,或者结合你当前的系统(Ubuntu / CentOS / macOS)给你具体示例。