But this has no effect. The interface comes up with a random address, again.
How ever, using ip link set bat0 down; ip link set bat0 address 02:00:02:00:00:01; ip link set bat0 up works.
Question 1: Is there maybe a bug or is 'interface' just the wrong place to configure the mac address for a batadv interface?
Question 2: Can I and if yes, how can I execute a script after bat0 is created and brought up, so I can change the mac address?
#!/bin/sh
[ "$ACTION" = "ifup" -a "$INTERFACE" = "bat0" ] && {
ip link set $INTERFACE down
ip link set $INTERFACE address 02:00:02:00:00:01
ip link set $INTERFACE up
}
But this is rather not not so nice. I would still prefer using option macaddr within /etc/config/network.
You can use something like this, you can remove the commit and sync if you don't want to persist the changes between reboots, and you can use uci revert network after that to clear the changes history too.
Thanks for pointing out how to do it with uci, but...
I'm really uncomfortable with using uci and like to change files, and restarting a service or at worst, a reboot. I find it really hard to interact with uci directly, but that's maybe a personal affair.
In this case I want a persistent behavior, because it drives me nuts if I need to check and double check 3 times which mac address bat0 does have this time.
The "not so nice" statement was meant that any extra fiddle script afterwards is not so nice. I would do this only with options or usecases not covered by the current openwrt scripts which build a config out of the /etc/config files.