Rename hostname and ssid with EUI of mac address#1370
Rename hostname and ssid with EUI of mac address#1370rosysong wants to merge 3 commits intoopenwrt:masterfrom
Conversation
8f34906 to
bdf62df
Compare
|
@rosysong I think, that for this feature to be widely useful, it would be handy to get EUI from the primary MAC address, the MAC address which is usually printed on the sticker somewhere on the router. Otherwise the router is going to welcome me with nice For that primary MAC address we would probably need to add something to DTS? and I think, that such Maybe a nitpick, but you've probably missed to add |
|
This commit does need to add something in DTS file, the ssid and hostname will set as long as you has relevant mac address in /proc/sys/xxx/macaddress. |
SSID is probably ok, since you're taking that MAC address from the phy. But for the hostname, I would expect, that it would be set to something I can verify physically on the device, so if I connect to device with hostname Some of the devices have all MAC addresses printed on the sticker, some of the devices have only WiFi MAC on the sticker, some of the devices have LAN or WAN MAC address. So you shouldn't use just |
|
I list the interfaces under /sys/class/net and get one of them as ifname, if succeed, we got the hostname. @ynezz |
|
Well, it seems like you don't get my comments at all. |
Yes, I think you are right, we should do something to specify which mac is the primary mac address. I agree with your opinion, but how can I get its value after I add the alias in DTS file ??
OK, will update them. |
|
@ynezz Here is the newer commit, it provides a new implementation for renaming hostname and eui. |
b305e32 to
9b48f3d
Compare
@ynezz I like that idea, as I need the "sticker MAC address" in a similar use-case as you referenced from Gluon. So, if one defined an alias as suggested, I could then access it via I will play around with this a litte bit. |
|
Well, actually it is as easy as adding to lib/functions/system.sh I will try my luck with a PR. |
for this PR, users do not need to update the DTS files but to set the primary mac address in the preinit scripts (e.g. target/linux/ath79/base-files/etc/board.d/02_network) with "ucidef_set_primarynetif ethxx". |
Yes. I just picked the improvement suggestion from ynezz, as it serves well to solve another problem I have. (And I also prefer specifying the primary-mac device in DTS). I actually like your initial idea of providing specific SSID/Hostname, so let's see how this goes on ... |
Once we figure out PR #2159 this PR could simply use |
|
Note that it looks like not every device is storing the relevant MAC addresses in device_tree. Here we will (maybe only after PR #2159 is sorted out) have to decide whether
So far, I'm personally far from having a preference. |
|
@rosysong My PR #2159 for adding label MAC addresses has just been accepted. Do you want to update this PR based on it or should I take over from here? Note that only a fraction of devices are supported, so the features introduced here will be limited to a (hopefully growing) subset of devices; I would suggest to keep the rest with the default "OpenWrt". |
There was a problem hiding this comment.
This would become:
local labelmac=$(get_mac_label)
local ssid=OpenWrt_11${mode_band}
[ -n "$labelmac" ] && ssid="${ssid}_$(macaddr_geteui $labelmac)"
There was a problem hiding this comment.
Here, you would delete the set system.@system[-1].hostname='OpenWrt' in the uci batch above and then add
local labelmac=$(get_mac_label)
if [ -n "$labelmac" ]; then
set system.@system[-1].hostname="OpenWrt_$(macaddr_geteui $labelmac)"
else
set system.@system[-1].hostname=OpenWrt
fi
before the "if json_is_a ..." block.
The remaining changes in this patch can be dropped.
There was a problem hiding this comment.
This patch can be dropped entirely, as MAC address will come from get_mac_binary directly (which internally uses something similar ...)
|
@adrianschmutzler Thanks, will update this PR later! Glad to see this. |
|
@adrianschmutzler @ynezz It's done, please check it again, thanks for your reivews! |
There was a problem hiding this comment.
Brackets for $ssid seem to be wrong here.
|
For the last commit, maybe rephrase "Once the label is valid" into something like "If a label MAC address is provided for device". |
There was a problem hiding this comment.
AFAIK underscores are not allowed in the hostnames, so this should be a hyphen.
There was a problem hiding this comment.
Don't add bands to SSIDs, you're effectively creating two different networks, forbidding band steering etc.
|
Thanks, here is the newer commit. |
|
It's done, thansk! ping @adrianschmutzler @ynezz |
This commit add a function for getting the external unique identifier of a mac address. Signed-off-by: Rosy Song <[email protected]>
If the label MAC is provided for device, the SSID
would be OpenWrt_{the eui of the mac address}
Signed-off-by: Rosy Song <[email protected]>
If a label MAC address is provided for device, system
will rename the hostname with OpenWrt_{eui mac address}.
This helps to distinguish between different devices.
Signed-off-by: Rosy Song <[email protected]>
|
@adrianschmutzler Well, I updated it, replace "set" with "uci set". |
|
I've merged the geteui patch and a rebased version of the hostname patch together and sent it to the mailing list: This was necessary as I plan to alter the label MAC address retrieval from get_mac_label function to uci config beforehand: Despite, I tried to test the WiFi patch, but found that this won't work for addresses being set up via /etc/board.json or /etc/config/system as mac80211.sh runs way earlier. |
Could you give me more details on what you want/need, so I can make sure it will work properly :) |
|
@mgiganto Well, essentially have a look at the second patch here. This will work if label MAC address is stored in device tree, and won't work if it's stored in board.json or uci config. |
It looks to be related with board.json being generated just after wifi config... I'll keep you update with the fix |
|
There has been demand for discussing this further in the mailing list. Despite, SSID name changes in mac80211.sh won't work as done here, as board.json is not available reliably. I will implement a solution with uci-defaults and submit that together with the hostname patch. |
|
Based on the feedback on the mailing list, this feature seems to be not desired. I've marked my/our patches as "Rejected". However, due to the introduction of the label MAC address one may easily do a similar adjustment of SSID/hostname in a short local uci-defaults script. |
This commit can meet the need of users who has more than 1 routers running with OpenWrt,
so that they can better distinguish between routers running OpenWrt without renaming the hostname and wifi ssid one by one.