Joel's dev blog

Changing mac address semi permanently

September 21, 2017

1 min read

How to

Dead simple.

Open up the file /etc/network/interfaces. It will show you something like:

# This file describes the network interfaces avilable on your system 
# and how to activate them. For more information, see interfaces(5).

source etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

and add at the end of the file, this line:

pre-up ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

This will spoof your mac address to xx:xx:xx:xx:xx:xx every time your computer boots up.

The better how to

But the above solution sets your mac address to the same value every time.So you might wanna use macchanger:

pre-up macchanger -r eth0 
pre-up macchanger -r wlan0

Adding these lines to /etc/network/interfaces file will set the mac addresses to random values every time your computer wakes up.


Written by Joel Mun. Joel likes Typescript, React, Node.js, GoLang, Python, Wasm and more. He also loves to enlarge the boundaries of his knowledge, mainly by reading books and watching lectures on Youtube. Guitar and piano are necessities at his home.

© Joel Mun 2023