Follow by Email

Blog Archive

Search This Blog

Change Raspberry Pi MAC address

Raspberry Pi change MAC address Each network interface or network adapter has its own hardware address, which is unique in the world and never changes.
Share it:
Raspberry Pi change MAC address
Change Raspberry Pi MAC address
Each network interface or network adapter has its own hardware address, which is unique in the world and never changes. The manufacturer assigned this hardware address during production. However, this hardware address in the form of the MAC address can be changed at runtime.
task
  • Change the MAC address temporarily with "ip".
  • Change the MAC address temporarily with "ifconfig".
  • Permanently change MAC address with "macchanger".
  • Change MAC address in the boot configuration of a Raspberry Pi.
Note: Name of the network interfaces
Since Raspbian Stretch, the Ethernet and WLAN network interfaces have different names. So no longer "eth0" and "wlan0", but "enx ..." and "wlx ...". This concerns USB-connected network adapters whose names differ from the designations mentioned here. This means that one must first determine the individual name or change the naming to the old method.
Note: Changing the MAC address not via SSH
The following settings should be made locally on the system, not SSH. If the MAC address changes while a connection is in progress, it will be like disconnecting the connection physically.

As a rule, the change will be made to the ethernet interface "eth0". You can also make the change on a WLAN interface. If you're unsure if it works or not, that's better. Because the wireless USB adapter can be replaced.

Solution 1: Temporarily change the MAC address with "ip"
The procedure is as follows: First, disable the interface. Then change the MAC address and activate the interface again.
sudo ip link set eth0 down
sudo ip link set eth0 address 00: 11: 22: 33: 44: 55
sudo ip link set eth0 up

Then check whether the change has been accepted.
ip l

Note: The change of the MAC address is temporary. After a restart, the MAC address returns to the old one.

Solution 2: Temporarily change the MAC address with "ifconfig"
Again, the network interface is taken out of service first. Subsequently, the MAC address changed and the network interface put back into operation.
sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether 00: 11: 22: 33: 44: 55
sudo ifconfig eth0 up

Check change of MAC address:
ifconfig

Note: The change of the MAC address is temporary. After a restart, the MAC address returns to the old one.

Solution: Permanently change MAC address with "macchanger"
First, we need to install a program that can change the MAC address.
sudo apt-get install macchanger

"macchanger" can ensure that an interface always gets a new MAC address as soon as it is activated. This means that even after a restart, an interface always has a different MAC address.

Command for setting a random MAC address:
sudo ip link set eth0 down
sudo macchanger -r eth0
sudo ip link set eth0 up

Then check to see if the hardware address has been changed.
ip l

Note: After a restart, the MAC address returns to the old one. Changing the MAC address is temporary, unless you have instructed "macchanger" to always use a different MAC address.

Solution: Change MAC address in the boot configuration of a Raspberry Pi
There is a way to change the MAC address in the boot configuration. This way you do not have to make the change manually.
To change the MAC address of the integrated Ethernet adapter, append the following entry with a space to the line in the file "/boot/cmdline.txt".
smsc95xx.macaddr = 00: 11: 22: 33: 44: 55

Note: This works only for the integrated Ethernet adapter and can not be set for any interface.

Note: It is expected that the changes via the boot configuration will eventually stop working. Therefore, this solution is the one to discourage.

Troubleshooting: Change MAC address does not work
There are constellations that do not allow changing the MAC address of a network interface. The reasons are many. On the one hand, we have a network adapter with a chipset that allows no change. On the other hand, this feature may not be supported in the driver.
Sometimes a software or driver update helps. Sometimes you have to use a different network adapter.
Share it:

Raspberry Pi

Post A Comment:

0 comments: