luci icon indicating copy to clipboard operation
luci copied to clipboard

luci-mod-network: wireless.js: add wifi-iface macaddr random support

Open msvamp opened this issue 2 years ago • 10 comments

Add ability to choose random or custom macaddr for wifi-iface

wifi-iface macaddr option

Choosing the new randomly generated MAC address option will cause a new MAC address to be generated whenever the WiFi interface is (re-)configured or the system is rebooted.

This will work only if wifi-iface supports option macaddr 'random'. Depends on https://github.com/openwrt/openwrt/pull/10307

msvamp avatar Jul 25 '22 06:07 msvamp

Why not add a button to generate a random Mac? Instead of a select?

Il Lun 25 Lug 2022, 08:00 Manas Sambhus @.***> ha scritto:

Add ability to choose random or custom macaddr for wifi-iface

[image: wifi-iface macaddr option] https://user-images.githubusercontent.com/51392775/180708159-74ccb91b-97a1-4c81-8ae2-4f4ca7cf445c.png

This will work only after openwrt/openwrt#10307 https://github.com/openwrt/openwrt/pull/10307 is merged.

You can view, comment on, or merge this pull request online at:

https://github.com/openwrt/luci/pull/5896 Commit Summary

File Changes

(1 file https://github.com/openwrt/luci/pull/5896/files)

Patch Links:

  • https://github.com/openwrt/luci/pull/5896.patch
  • https://github.com/openwrt/luci/pull/5896.diff

— Reply to this email directly, view it on GitHub https://github.com/openwrt/luci/pull/5896, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2ZMQWYRA4KQIQ634TPIXTVVYURNANCNFSM54RAYZQQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Ansuel avatar Jul 25 '22 06:07 Ansuel

Why not add a button to generate a random Mac?

@Ansuel The purpose of adding a macaddr random option to wifi-iface was to ensure a new random MAC address is generated everytime the interface (or the router itself) is restarted. Please have a look at https://github.com/openwrt/openwrt/pull/10307.

msvamp avatar Jul 25 '22 06:07 msvamp

Oh ok sorry for the noise then.

Il Lun 25 Lug 2022, 08:16 Manas Sambhus @.***> ha scritto:

Why not add a button to generate a random Mac?

@Ansuel https://github.com/Ansuel The purpose of adding a macaddr random option to wifi-iface was to ensure a new random MAC address is generated everytime the interface (or the router itself) is restarted. Please have a look at openwrt/openwrt#10307 https://github.com/openwrt/openwrt/pull/10307.

— Reply to this email directly, view it on GitHub https://github.com/openwrt/luci/pull/5896#issuecomment-1193626810, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2ZMQVMKZOKGOUHMK6FWC3VVYWMZANCNFSM54RAYZQQ . You are receiving this because you were mentioned.Message ID: @.***>

Ansuel avatar Jul 25 '22 06:07 Ansuel

Wonder if you should add some reference about this in the commit description. Anyway good work.

Ansuel avatar Jul 25 '22 06:07 Ansuel

@Ansuel Updated commit and PR description

msvamp avatar Jul 25 '22 08:07 msvamp

Is it possible to allow random/custom mac enabled by default? I mean to make the Openwrt router forget about the original factory MAC address at all, and never expose the original factory MAC address anytime anywhere, in order to prevent accidental leakage(during first time setup for example). Broadcasting real MAC address is just too...big brother. I suggest to allow to choose between Permanent/Temporary/Factory MAC and manual regenerate for the button design.

Che15ea avatar Aug 09 '22 05:08 Che15ea

No, it will most likely not become the default as it would break existing setups relying on specific MACs for DHCP lease reservations etc.

jow- avatar Aug 09 '22 09:08 jow-

@Che15ea I agree with @jow-, most people would prefer to use the router's default MAC address wherever possible, and opt in to using a randomised MAC only for some specific interfaces. Some have a network setup relying on MAC address for address assignment, access control etc. and also, there are some ISPs that identify a customer's device by MAC address and block access otherwise - hence using a randomized MAC by default would be troublesome for them.


Is it possible to allow random/custom mac enabled by default? I mean to make the Openwrt router forget about the original factory MAC address at all

If you need such a firmware, you can easily build one for yourself with the OpenWrt Imagebuilder. On most platforms, the /etc/board.d/xx_network script is responsible for configuring the correct MAC address for the router by reading it from some flash partition or firmware folders in the kernel. You can replace this file with your own, that calls the macaddr_random() function in place of the correct procedure defined for your device. Note that in most cases, this would also alter your ethernet MAC address, so be careful.

in order to prevent accidental leakage(during first time setup for example)

If referring to just wireless, I don't think that the original MAC address is leaked during the initial setup, because the wireless interfaces are disabled by default. You should be able to customise the settings and enable the interfaces only once done.

I suggest to allow to choose between Permanent/Temporary/Factory MAC and manual regenerate for the button design.

Thank you for the suggestion. I'll consider adding a button to generate a new random MAC address (in a separate PR). Currently, with the new randomly generated option that I've added, the MAC address is randomised whenever the WiFi interface is (re-)configured, so I believe that using the restart button in LuCI for that interface, should also create a new MAC address for it.

msvamp avatar Aug 09 '22 18:08 msvamp

I merged https://github.com/openwrt/openwrt/pull/10307 and think this PR is fine, @jow- ?

aparcar avatar Aug 11 '22 15:08 aparcar

I hope the 2 options in the select list are clear enough and are not misinterpreted 🙃

Also, do we need a custom validation message?

msvamp avatar Aug 11 '22 15:08 msvamp

Is this "Network -> Interfaces -> Devices -> Configure -> Mac address", and going to be applied to all device types, not just Wi-Fi? I want to randomise the MAC address of my "WAN" device, so that my ISP would give a random IP, because the ISP always gives the same IP for the same MAC address.

If I have set "randomly generated" to the Mac address of my WAN device, and I click "Network -> Interfaces -> WAN-> Restart", my WAN device's Mac address will be changed to a random address without restarting the whole router, right?

HubKing avatar Nov 08 '22 07:11 HubKing

@HubKing The change that I implemented was only for MAC randomisation for Wi-Fi interfaces, not Ethernet or other kinds of interfaces.

If your WAN connection is over a wireless interface, then MAC randomisation will surely work for it. You can change the MAC address by restarting the WiFi interface, without having to restart the router.

msvamp avatar Nov 21 '22 06:11 msvamp

@HubKing The change that I implemented was only for MAC randomisation for Wi-Fi interfaces, not Ethernet or other kinds of interfaces.

If your WAN connection is over a wireless interface, then MAC randomisation will surely work for it. You can change the MAC address by restarting the WiFi interface, without having to restart the router.

No, my WAN is not Wi-Fi; like most people, it is wired connection to a broadband modem from my ISP. Can't the same random feature applies to Ethernet (wired) MAC address, too?

HubKing avatar Nov 27 '22 02:11 HubKing

Can't the same random feature applies to Ethernet (wired) MAC address, too?

@HubKing For this, one will have to look at the corresponding scripts for ethernet device setup and add the change there (just like I did for wireless interfaces).

This is a good idea though, I'll try to implement this when I get some time (probably in late December).

msvamp avatar Nov 27 '22 05:11 msvamp

@aparcar I have implemented your suggestion about keeping the MAC address visible, but only if it is not randomised. (Or I can also add the check for macaddr to be empty/unset rather than checking against random)

@jow- Are we good to merge now?

msvamp avatar Apr 29 '23 19:04 msvamp

Ping. 🙂 @Ansuel @aparcar @jow-

msvamp avatar May 30 '23 19:05 msvamp

@msvamp can you update the screen with new implementation?

Ansuel avatar Jun 15 '23 17:06 Ansuel

@msvamp can you update the screen with new implementation?

@Ansuel Edited my first comment to add new screenshots

msvamp avatar Jun 19 '23 18:06 msvamp