Open In App
Related Articles

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

Improve Article
Save Article
Like Article

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.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 16 Mar, 2021
Like Article
Save Article
Similar Reads
Related Tutorials