模板:RTL8125 MAC SINGLE EN
The 2.5G Ethernet port uses the RTL8125 network card, and during use, the MAC address is not fixed. Each time the device is powered on again, the MAC address changes randomly. The following explains how to set a fixed MAC address for the RTL8125 network card.
This explanation also applies to the Ubuntu system.
First, check the identification information of the RTL8125 network card in terminal:
ipconfig -a
Here, the RTL8125 network card is identified as eth1, but in practice, the name recognized by the system might be different.
Then input:
sudo mousepad /etc/systemd/system/macspoof@eth1.service
Or:
sudo nano /etc/systemd/system/macspoof@eth1.service
eth1 is the name recognized by the system for the network card shown above.
Executing the above command will create a new document, then enter the following text:
[Unit]
Description=MAC Address Change %I
Wants=network-pre.target
Before=network-pre.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
[Service]
Type=oneshot
ExecStart=/usr/bin/ip link set dev %i address xx:xx:xx:xx:xx:xx
ExecStart=/usr/bin/ip link set dev %i up
[Install]
WantedBy=multi-user.target
Here, "xx:xx:xx:xx:xx:xx" represents the MAC address you wish to assign. You can determine it according to the MAC address format (make sure it does not duplicate the MAC address of other network devices). After setting it, save and exit.
Then execute the following command to enable the service:
sudo systemctl enable macspoof@eth1.service
This completes the fixation of the MAC address for eth1.
After completing all operations, restart the system. Once the system has finished rebooting, execute ipconfig -a
to see that the MAC address has been successfully changed.