Changing MAC address presented to Network

Is it possible in OpenWrt to change the MAC address that is presented to the wifi network it connects to in Client mode?

Ideally I would like to change the MAC address to one from a list either within the config (maybe randomly when I reboot router or restart the radio) or to have a file of say a hundred MAC addresses in a text file that it works its way through.

The reason I want to do this is to test whether my connection is being throttled after a certain amount of use or whether it is environmental or down to use by others.

In luci, network, -> interfaces -> advanced settings you can override the mac address of a specific network interface.

3 Likes

It's not exactly what you want, but you could randomize the radio1 mac address, based on this script. Edit default_radio1 if it is not the correct wifi-iface.

cat << "EOF" > /root/wifimac
#!/bin/sh

uci set wireless.default_radio1.macaddr=$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/') && wifi

exit 0
EOF
chmod 755 /root/wifimac

Insert /root/wifimac in /etc/rc.local above exit 0
You will have a different radio1 mac address after each restart. If you want to change the mac address without restarting the router, just type /root/wifimac

4 Likes

Simply add this to your wifi-iface section:

option macaddr 'xx:xx:xx:xx:xx:xx'

To make it random....another thing (the above seems interesting :thinking: ).

1 Like

Thanks for posts so far!

Two further questions:

  1. Does OpenWrt present the same Mac Address externally (facing the wifi it is connection to (as client or AP) and internally within the Lan?

  2. Is there a command to list all the mac addresses of all the interfaces on an OpenWrt install?

As the mac address belongs to a network interface, it is visible to everybody who accesses that network interface. I just checked my installation. LAN and Guest Wifi have the identical mac address, as I did not change it.

the command ip addr show shows all ip interfaces, the mac addresses are listed in the line link/ether under each interface

1 Like

Thanks, I tried that command but they all show the same Mac Address but I have different ones displayed in Luci

I would first try a reboot, and if the difference persists, maybe give us the details (with anonymized MAC-adresses MAC-1, MAC-2, ...).

1 Like

OK I ran the command, the results are below I anonymized the MAC addresses, many were not changed, they are shown in bold.

Where would I change those?

Also what are sections 4 to 6 and where would I edit them?

/etc/config$ ip JJdr show

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever

2: eth0: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 9Q:GG:JJ:99:9Q:Z4 brd ff:ff:ff:ff:ff:ff
inet6 fe80::LUGG:JJff:fe99:9QZ4/64 scope link
valid_lft forever preferred_lft forever

3: eth1: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 9Q:GG:JJ:99:9Q:Z3 brd ff:ff:ff:ff:ff:ff
inet6 fe80::LUGG:JJff:fe99:9QZ3/64 scope link
valid_lft forever preferred_lft forever

7: br-lan: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether d4:e5:f6:a1:b2:c3 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global br-lan
valid_lft forever preferred_lft forever
inet6 fe80::d4e5:f6ff:fea1:b2c3/64 scope link
valid_lft forever preferred_lft forever

8: eth1.1@eth1: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
link/ether 9Q:GG:JJ:99:9Q:Z3 brd ff:ff:ff:ff:ff:ff

9: br-wan: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 9Q:GG:JJ:99:9Q:Z4 brd ff:ff:ff:ff:ff:ff
inet 192.168.50.254/24 brd 192.168.50.255 scope global br-wan
valid_lft forever preferred_lft forever
inet6 fe80::LUGG:JJff:fe99:9QZ4/64 scope link
valid_lft forever preferred_lft forever

10: eth0.2@eth0: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-wan state UP qlen 1000
link/ether 9Q:GG:JJ:99:9Q:Z4 brd ff:ff:ff:ff:ff:ff

11: wlan0: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 9Q:GG:JJ:99:9Q:Z5 brd ff:ff:ff:ff:ff:ff
inet 100.90.89.87/16 brd 100.90.255.255 scope global wlan0
valid_lft forever preferred_lft forever
inet6 fe80::LUGG:JJff:fe99:9QZ5/64 scope link
valid_lft forever preferred_lft forever

12: wlan1: <BROJJCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
link/ether 9Q:GG:JJ:99:9Q:Z6 brd ff:ff:ff:ff:ff:ff
inet6 fe80::LUGG:JJff:fe99:9QZ6/64 scope link
valid_lft forever preferred_lft forever

1 Like
  1. I also have gaps in the output numbering of ip addr show.
  2. please post and compare the content of /etc/config/network and /etc/config/wireless with the mac addresses of the ip address show output for each interface.

See https://unix.stackexchange.com/questions/571183/how-to-change-eth0-mac-address-only-using-a-text-editor
on how the /etc/config/network should look like.
For /etc/config/wireless:

Please anonymize the mac addresses.

1 Like

I will do this, it takes time and I want to group them with copy of the settings to make it make more sense.

Are etc/config/network and /etc/config/wireless the only places one can change mac address?

I am not aware of any other place.

1 Like

please show me how can I apply that I m beginner on commands