温馨提示×

linux ifconfig如何改mac地址

小樊
33
2026-09-17 04:00:32
栏目: 智能运维

在 Linux 中,使用 ifconfig 修改 MAC 地址(俗称“MAC spoofing”)的一般步骤如下:

⚠️ 前提说明

  • 需要 root 权限
  • 网卡名称示例为 eth0(无线可能是 wlan0
  • 新 MAC 必须是合法格式,如 00:11:22:33:44:55

一、使用 ifconfig 修改 MAC 地址

1️⃣ 先关闭网卡

sudo ifconfig eth0 down

2️⃣ 修改 MAC 地址

sudo ifconfig eth0 hw ether 00:11:22:33:44:55

3️⃣ 重新启用网卡

sudo ifconfig eth0 up

4️⃣ 验证是否修改成功

ifconfig eth0 | grep ether

ip link show eth0

二、恢复原始 MAC 地址

重启网卡通常会恢复:

sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether 原MAC地址
sudo ifconfig eth0 up

或重启系统。


三、注意事项(很重要)

  1. ifconfig 已逐步被弃用

    • 新系统推荐使用 ip 命令:
      sudo ip link set eth0 down
      sudo ip link set eth0 address 00:11:22:33:44:55
      sudo ip link set eth0 up
      
  2. 网络会短暂中断

  3. 某些驱动/网卡不支持改 MAC

  4. 不要用于非法用途(如蹭网、伪装攻击)


如果你愿意,可以告诉我:

  • 你的 Linux 发行版(Ubuntu / CentOS / Arch 等)
  • 有线还是无线网卡

我可以给你更精确的命令。

0