Open In App
Related Articles

How to get Client IP address and MAC address in Laravel ?

Like Article
Save Article
Report issue

What is a MAC address?
MAC is the abbreviation of “Media Access Control” and it is a 48-bit physical address associated with every networking device. It is printed on the NIC (Network Interface Card) and is globally unique for every networking device. MAC address is used by the data-link layer to route a data packet from source to destination.

How to get the MAC address of the connected client in Laravel?

The ‘exec()’ is a function that is used to run an external program in PHP. It returns the last line from the result of the command. To get the MAC address, pass the parameter ‘getmac’ which returns the MAC address of the client. ‘getmac’ is a CMD command to get the MAC address.

To get the MAC address, we use exec() function.

$macAddr = exec('getmac');

What is an IP address?
An Internet Protocol(IP) address also known as a logical address is given by the internet service provider(ISP) which uniquely identifies a system over the network. IP address keeps on changing from time to time.

How to get the IP address of the connected client in Laravel?

For getting the IP address we have to include use Illuminate\Http\Request; in the Controller and then add the code of the below pre tag. It will give the AP address of the network.


Last Updated : 16 Mar, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads