Get Bluetooth MAC Address via adb

27,702

Solution 1

Running netcfg will show you all interfaces on the system along with their MAC addresses.

Solution 2

adb shell cat /sys/class/net/wlan0/address

Solution 3

What I usually do to get the mac address of the WiFi interface of an Android device (that is connected to my PC through a USB port) is following these easy steps:

1. Find the device name using:

adb devices

Results usually looks like:

List of devices attached 
4e7354af  device
1f97033e  device

In this case we have two devices connected 4e7354af and 1f97033e. Let's work on the first one: 4e7354af

2. Get the mac address for the first device:

adb -s 4e7354af shell "ip addr show wlan0  | grep 'link/ether '| cut -d' ' -f6"

The result will be looks like:

8e:5a:e7:c2:01:9b

In previous line, we used the -s option of the adb command to specify the serial number. Then we call the shell command to indicate that we will run a Linux command. Finally, we run the command: ip addr show wlan0 | grep 'link/ether '| cut -d' ' -f6 this command can also be used in Linux if its interface has the same name as wlan0.

I generally use this approach because I have many devices connected to my testing environment. Good luck guys.

Note: If you run commands like cat /sys/class/net/wlan0/address you will get an error like cat: /sys/class/net/wlan0/address: Permission denied due to the security policies of Android.

Solution 4

Isn't bluetooth MAC address available on every Android phone in Settings?

Currently I have 2 devices near:

On Samsung Galaxy S2 - Settings > About Phone > Status

On HTC Desire - Settings > About Phone > Hardware Information

(Bluetooth must be turned on)

Share:
27,702
Antonio
Author by

Antonio

Updated on July 19, 2021

Comments

  • Antonio
    Antonio almost 3 years

    Please help me to retrieve the Bluetooth MAC Address of my Galaxy S3 phone connected via USB port. My device is rooted.

  • Santiago Villafuerte
    Santiago Villafuerte over 8 years
    It works. The Bluetooth MAC address shows up as pan0.
  • Gene Pavlovsky
    Gene Pavlovsky over 7 years
    The best, no-nonsense, answer. ifconfig doesn't list the MAC address, there's no netcfg on my Moto G 2015.
  • Gene Pavlovsky
    Gene Pavlovsky over 7 years
    My Moto G 2015 doesn't have netcfg command. Running AICP ROM.
  • Karthik T
    Karthik T over 7 years
    This should be the accepted answer
  • imknown
    imknown almost 7 years
    Need root permission on my android.
  • Alexandre Willame
    Alexandre Willame about 6 years
    This provides me with the Wifi mac address but not the BT one.....
  • Antony Booth
    Antony Booth about 3 years
    This is the best answer (ip addr show wlan0) when "ifconfig" doesn't display a mac address, regardless of command line arguments, "netcfg" isn't installed, which is common and when adb lacks sufficient privileges to read "/sys/class/net/wlan0/address" because the device isn't rooted. Many thanks.