Get Wifi Client Mac For Airelay

Active30 days ago

Get Wifi Client Mac For Airplay For Windows

In client mode, the AirPort Express is used exclusively by the device to which it is physically connected. It won't extend the range of the Wi-Fi network, meaning that other devices, such as computers, cannot connect to it wirelessly. AirPlay, which is Apple's technology for wireless media streaming, lets your computer or iOS device send music, photos, podcasts, and videos to devices throughout your house or office. For instance, if you want to stream music from an iPhone X to a Wi-Fi speaker, you use AirPlay. The article doesn't really explain why you might want to use client mode (other than use as a WiFi adapter for some equipment) which could lead someone to think this is necessary for AirPlay 2 targets.

I need to know the MAC and the IP address of the connect clients, how can I do this in PHP?

164k33 gold badges323 silver badges637 bronze badges
9253 gold badges13 silver badges22 bronze badges

12 Answers

Server IP

You can get the server IP address from $_SERVER['SERVER_ADDR'].

Server MAC address

For the MAC address, you could parse the output of netstat -ie in Linux, or ipconfig /all in Windows.

Client IP address

You can get the client IP from $_SERVER['REMOTE_ADDR']

Client MAC address

The client MAC address will not be available to you except in one special circumstance: if the client is on the same ethernet segment as the server.

So, if you are building some kind of LAN based system and your clients are on the same ethernet segment, then you could get the MAC address by parsing the output of arp -n (linux) or arp -a (windows).

Edit: you ask in comments how to get the output of an external command - one way is to use backticks, e.g.

But what if the client isn't on a LAN?

Well, you're out of luck unless you can have the client volunteer that information and transmit via other means.

Paul DixonPaul Dixon
253k42 gold badges288 silver badges324 bronze badges

The MAC address of a client (in the sense of the computer that issued the HTTP request) is overwritten by every router between the client and the server.

Client IP is conveniently provided to the script in $_SERVER['REMOTE_ADDR']. In some scenarios, particularly if your web server is behind a proxy (i.e. a caching proxy) $_SERVER['REMOTE ADDR'] will return the IP of the proxy, and there will be an extra value, often $_SERVER['HTTP_X_FORWARDED_FOR'], that contains the IP of the original request client.

Sometimes, particularly when you're dealing with an anonymizing proxy that you don't control, the proxy won't return the real IP address, and all you can hope for is the IP address of the proxy.

Michał TatarynowiczMichał Tatarynowicz
7492 gold badges9 silver badges31 bronze badges

I don't think you can get MAC address in PHP, but you can get IP from $_SERVER['REMOTE_ADDR'] variable.

45.9k20 gold badges114 silver badges146 bronze badges

All you need to do is to put arp into diferrent group.



With command:

you will get:

And because apache is a daemon running under the user www-data, it's now able to execute this command.

So if you now use a PHP script, e.g.:

you will get the output of linux arp -an command.

Cosmin Pirvu
19.7k5 gold badges35 silver badges56 bronze badges

This is a PHP class for MAC address manipulation on top of Unix, Linux and Mac OS X operating systems. it was primarily written to help with spoofing for wireless security audits.

3,7982 gold badges17 silver badges36 bronze badges

In windows, If the user is using your script locally, it will be very simple :


You can get MAC Address or Physical Address using this code

I used explode many time because shell_exec ('ipconfig/all') return complete detail of all network. so you have to split one by one. when you run this code then you will get
your MAC Address00-##-##-CV-12 //this is fake address for show only.

Pankaj KumarPankaj Kumar

You can use the following solution to solve your problem:

Grant Miller
8,59213 gold badges47 silver badges74 bronze badges
AbdulRahman AlShamiriAbdulRahman AlShamiri

This works for me on Windows, as ipconfig /all is Windows system command.

Kevin Guan
14.7k10 gold badges44 silver badges71 bronze badges
3191 gold badge5 silver badges15 bronze badges

under linux using iptables you can log to a file each request to web server with mac address and ip.from php lookup last item with ip address and get mac address.

As stated remember that the mac address is from last router on the trace.


You can do this easily using openWRT. If yo use a captive portal you can mix php and openWRT and make a relation between the IP and the mac.

You can write a simple PHP code using:

Later, using openWRT you can go to /tmp/dhcp.leases, you will get something with the form:

There, you have the mac, the IP address and the hostname.

Setup Mac For Airplay

Bernat Pedrol VozmedianoBernat Pedrol Vozmediano

protected by CommunityJan 11 '12 at 9:16

Use Airplay Without Wifi

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

Get Wifi Client Mac For Airplay 2

Not the answer you're looking for? Browse other questions tagged phpmac-address or ask your own question.