# 在Kali Linux中修改网卡Mac地址

通过修改网卡的MAC地址可以使得Kali Linux在做hack活动之前避免被反向跟踪。

在修改任何网络设备前需要确保已经关闭（down）了设备，然后再运行修改MAC地址的命令。

## 修改有线网卡MAC地址

如果需要修改`eth0`网卡的MAC地址，需要首先使用

```
ifconfig eth0 down
```

确保该网卡设备停止，然后再修改网卡：

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

然后再次UP起网卡接口，确认MAC地址已经修改成对应的MAC

```
ifconfig eth0 up
```

## 修改无线网卡MAC地址

如果要修改无线网卡的MAC地址，则基于使用的不同无线网卡，可能需要采用不同方式。

* 首先检查无线网卡：

```
iwconfig
```

输出显示

```
wlan0     IEEE 802.11bgn  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=31 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
```

* 关闭该无线网卡接口

```
ifconfig wlan0 down
```

然后再使用 `iwconfig` 检查无线网卡接口可以看到(Tx-Power已经去除)：

```
wlan0     IEEE 802.11bgn  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
```

* 使用`macchanger`工具修改无线网卡的MAC地址

```
macchanger -m 00:11:22:33:44:55 wlan0
```

然后启动无线网卡，检查网卡的MAC地址

```
ifconfig wlan0 up
```

* 要确保每次系统启动都能够正确修改MAC地址，需要在网卡配置文件 `/etc/network/interfaces` `最后`添加如下内容

```
pre-up ifconfig eth0 hw ether 00:33:55:77:99:00
```

然后重启网络服务

```
service network-manager restart
```

无线网络配置请参考 [Ubuntu 802.1x网络认证](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/os/linux/ubuntu/system_administration/network/802.1x_authentication) 和 [使用终端方式在Kali Linux中配置Wi-Fi网络](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/os/linux/kali/connect_wifi_from_terminal_kali_linux/README.md)

## 参考

* [Change Mac Address in Kali Linux(Permanently)](https://www.yeahhub.com/change-mac-address-kali-linux-permanently/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/os/linux/kali/change_mac_address_in_kali.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
