Orange Pi Zero wlan MAC address

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Orange Pi Zero wlan MAC address

Post by johnvick »

I have two of these devices and after a few frustrating days trying to get them both setup and running on the same LAN I have realised the problem is both have the same wlan MAC address - I presume therefore that all of these devices do. After some research this seemed to be the solution:

Code: Select all

#!/bin/sh

### BEGIN INIT INFO
# Provides:          macchanger
# Required-Start:    $network $syslog
# Required-Stop:     $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Changes the MAC address at boot time.
# Description:       Changes the wireless cards MAC addresses
### END INIT INFO


# Change the MAC address

ifconfig wlan0 down
ifconfig wlan0 hw ether DC:44:6D:D3:A6:77
ifconfig wlan0 up


exit 0
It works if you run it from the command line but I want to run it on boot.

I put the script in /etc/init.d and then

Code: Select all

chmod +x /etc/init.d/changemac.sh
Then

Code: Select all

update-rc.d changemac.sh defaults
Then reboot and:

Code: Select all

ifconfig -a
But the MAC is still the original.

What I doing wrong?

Thanks, John
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Orange Pi Zero wlan MAC address

Post by k-plan »

Hi John,

you can test, to manually edit /etc/network/interfaces

But I can't test it, sorry don't have a Orange Pi Zero.
If something going wrong, you will to put your sd-card into another Linux device and have to withdraw your changes.

Code: Select all

...

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid Not_Set
wireless-key MyAccessKey
wireless-mode Managed
wireless-power off
wpa-ssid Not_Set
wpa-psk MyAccessKey
dns-nameservers 8.8.8.8 8.8.4.4
hwaddress ether DC:44:6D:D3:A6:77
Or, if you want to use MACChanger

Code: Select all

...

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid Not_Set
wireless-key MyAccessKey
wireless-mode Managed
wireless-power off
wpa-ssid Not_Set
wpa-psk MyAccessKey
dns-nameservers 8.8.8.8 8.8.4.4
pre-up macchanger -m  DC:44:6D:D3:A6:77 wlan0

cu
k-plan
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Orange Pi Zero wlan MAC address

Post by johnvick »

Hi k-plan,

Thanks for these suggestions but no luck I am afraid.

in /etc/network/interfaces if I do the following:

Code: Select all

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
pre-up macchanger -m  DC:44:6D:D3:A6:77 wlan0
pre-up modprobe xradio_wlan
pre-up iwconfig wlan0 power on
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid MYSSID
wireless-key MYPWD
wireless-mode Managed
wireless-power off
wpa-ssid MYSSID
wpa-psk MYPWD
#dns-nameservers 8.8.8.8 8.8.4.4
I get close in that it does change the MAC but then I cannot get wifi to work. Of the other solutions I have looked at some change the MAC but getting the change to occur on boot has not been possible.

John
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Orange Pi Zero wlan MAC address

Post by k-plan »

Hi John,
johnvick wrote:Thanks for these suggestions but no luck I am afraid.
Sorry to here this.

Kernel and DietPi version?
Is the problem the onboard wifi?
Use it wifi module: " xradio_wlan "?
Is mac-address always -> DC:44:6D:D3:A6:7F ?

If so, can you please have a look:

Code: Select all

cat /etc/modprobe.d/xradio_wlan.conf

options xradio_wlan macaddr=DC:44:6D:D3:A6:7F
Sorry, but I only have the option to take a quick look into the last image file: DietPi_v139_OrangePiZero-armv7-(Jessie).img

... and the output of:

Code: Select all

macchanger -s wlan0
would be nice. Thanks.

cu
k-plan
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Orange Pi Zero wlan MAC address

Post by johnvick »

Hi k-plan,

Kernel : Linux Orange2 3.4.113-sun8i #2 SMP PREEMPT Mon Dec 5 19:40:45 GMT 2016 armv7l GNU/Linux
DietPi v142
On board wifi using module xradio_wlan
options xradio_wlan macaddr=DC:44:6D:D3:A6:7F

The MAC is always DC:44:6D:D3:A6:7F - does the above file therefore set this? Changeing it to another MAC stops wifi from working.
I can change it using the methods described above but then can't connect by wifi and I cannot get a change to survive a reboot.

macchanger -s wlan0
Current MAC: dc:44:6d:d3:a6:7f (unknown)
Permanent MAC: dc:44:6d:d3:a6:7f (unknown)
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Orange Pi Zero wlan MAC address

Post by k-plan »

Hi John,
johnvick wrote:Kernel : Linux Orange2 3.4.113-sun8i
Okay, you are on Legacy kernel images.

johnvick wrote:The MAC is always DC:44:6D:D3:A6:7F - does the above file therefore set this?
I think it should work, because I have read this hint here and here.

But have read as well from armbian
Board: Orange Pi Zero
  • Onboard wireless chip (XR819) has poor software support so wireless connection issues are expected
... and don't understand, how XR819 (xradio) support to set a mac-address: http://filez.zoobab.com/allwinner/h2/20 ... ss/xradio/

It could be useful to have a look in dmesg output for something like

Code: Select all

dmesg | grep xradio
dmesg | grep wlan0

[   11.922987] xradio_wlan: unknown parameter 'macaddr' ignored

Code: Select all

modinfo xradio_wlan
Have you seen Fourdee wifi fix here?

https://github.com/Fourdee/DietPi/issue ... -266006050


If your own script works, you can test to integrate it into xradio_wlan.service or run it via /etc/rc.local

Code: Select all

# rc.local

##  run changemac with a delay for example of 20 sec.
(/bin/sleep 20 && /etc/init.d/changemac.sh)

exit 0
But do it via systemctl will be a better way.

---------

(Or, if you want, you can test, whether DietPi for OrangePi Zero with Mainline kernel get another mac-address on your special device)
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Orange Pi Zero wlan MAC address

Post by johnvick »

Thanks k-plan for this detailed response - lots to try but first off I think I'll check out the new kernel.

Other than the MAC problem I've had other wifi issues that maybe this kernel will fix.

John
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Orange Pi Zero wlan MAC address

Post by johnvick »

I gave this a try:
(Or, if you want, you can test, whether DietPi for OrangePi Zero with Mainline kernel get another mac-address on your special device)
But couldn't get it going. Instead I tried Armbian and have got this working but when I do ifconfig -a I get a different MAC address.

The question is - does DietPi therefore assign a MAC address to the device? If not then how can two devices having the same MAC address be explained?

With the two devices now having different MAC addresses they can happily co-exist on the network, but Armbian take a lot of extra work to set stuff up.

John
Post Reply