get DHCP address of connection to router

✔ Recommended Answer

Likely not the cleanest solution, but if you are running Linux/Unix you can run the below php system call in your script. I have not tested it but I believe it will provide you with the correct IP in the variable. Just remember to switch en1 with your actual ethernet/wireless adapter name for your system. You may also need to use the exact path to the ifconfig command.

$ipAddress = system('ifconfig en1 | grep inet | cut -d" " -f2' , $returnVal);

Sorry if the variable names are not in the php standard, I normally develop in Java these days.

Source: stackoverflow.com

Answered By: Lipongo

Method #2

Assuming you are using a computer running Windows operating system, you can follow these steps to obtain the DHCP address of your connection to the router:

  1. Click on the Start menu and type "cmd" in the search bar. Press Enter to open the Command Prompt.

  2. In the Command Prompt, type "ipconfig" and press Enter.

  3. Look for the network adapter that you are using to connect to the router. It should be labeled "Ethernet adapter" or "Wi-Fi adapter," depending on your connection type.

  4. Under the network adapter, look for the "IPv4 Address" entry. This will display the DHCP address that was assigned to your connection by the router.

Note: If you are using a different operating system or device, the steps may be slightly different. However, the general process should be similar, and you can consult the documentation or support resources for your specific system or device for guidance.

Comments

Most Popular

Remove Unicode Zero Width Space PHP

PhpStorm, return value is expected to be 'A', 'object' returned

Laravel file upload returns forbidden 403, file permission is 700 not 755