[ArchLinux]random MAC-address for new wireless connections

I used to travel more over the past year. Goal was different places: England, Belgian. This means I also have to use untrusted wireless connection.

This leaves a good trace wherever you go. Simply by the fact that the MAC-Address being used every time you do a connection to any wlan. This is often stored, but How long? There are good example where this information is begin havest for money.

Beside, You never know who else listen and might want uses this data. To mitigate this problem I do following: I generate a random mac address for each new connection.

As an ArchLinux user I prefer to use the netctl tool. Within each new connection via a profile[1] with the netctl tool, it will by default source this two files:

/etc/netctl/hooks			# General script that will always be executed
/etc/netctl/interfaces		# Interface related scripts that will start when a profile uses this interface.

So I’ll simply call macchanger for the interface that being use.

The script should be place in /etc/netctl/interfaces/ with the name of the interface. Here wlan0 as example


The content of this file:

#!/usr/bin/env sh
/usr/bin/macchanger -r wlan0

Ensure that it can be executed:

chmod o+x /etc/netctl/interfaces/wlan0

Now whenever you start a profile that will use the wlan0 interface, it will be executing the /etc/netctl/interfaces/wlan0 script additional.


ip link show wlan0 |tail -n1|grep -m1 -E  '.([0-9,a-f]{2})'
 link/ether a2:0d:98:2d:ec:b5 brd ff:ff:ff:ff:ff:ff

New connection - In this case a restart:

netctl restart SomeWlan 
ip link show wlan0 |tail -n1|grep -m1 -E  '.([0-9,a-f]{2})'
 link/ether a2:4e:8d:2f:4a:3c brd ff:ff:ff:ff:ff:ff

Another try:

netctl restart SomeWlan 
ip link show wlan0 |tail -n1|grep -m1 -E  '.([0-9,a-f]{2})'
 link/ether 5a:d4:e5:4c:8f:ad brd ff:ff:ff:ff:ff:ff

You can do the same with the any other interface.

so far 4k3nd0

[1]man netctl.profile