IP (Internet Protocol) Address is an address of your network hardware. It helps in connecting your computer to other devices on your network and all over the world. An IP Address is made up of numbers or characters combined by ‘.’ symbol.
Example: It is an example of IP address.
All devices that are connected to an internet connection have a unique IP address which literally gives the idea that a large number of IP addresses had to be created for every system.
Local IP address: It is the IP address of your computer system which is meant to be kept private and thus is also known as private IP addresses. This article focuses on how to extract the IP address. A private IP address is the address of your device connected to the home or business network. If you have a few different devices connected to one ISP (Internet Service Provider), then all your devices will have a unique private IP address. This IP address cannot be accessed from devices outside your home or business network. Private IP addresses are not unique because there is a limited number of devices on your network. There are some other types of IP addresses that exist like, public IP addresses, static IP addresses and dynamic IP addresses that follow the same format for representation.
IPv4 address: The IPv4 version used to configure IP addresses in numerical value and it uses the hexadecimal number system to complete its job i.e. what makes it possible to get millions of IP, different for every system.
Example: In this example, we are trying to get the local IP address without using terminal and its commands. Instead, we are using a PHP program to get the same job done. We will be required two methods that are mentioned below:
- getHostByName() Function: It gets the IPv4 address corresponding to a given Internet host name.
- getHostName() Function: It gets the standard host name for the local machine.
- Program: Here, first we get the name of the local machine as the string and then by using that we will get the corresponding address to that name.
// Declaring a variable to hold the IP
// address getHostName() gets the name
// of the local machine getHostByName()
// gets the corresponding IP
// Displaying the address
The fact that no output is provided with this program because of security reasons. Sharing of IP addresses can lead to security breaches and one should be careful not to share it. Any unethical access can cost you theft of personal space and even identity.
- How to get the MAC and IP address of a connected client in PHP?
- How to Host a Local Server globally for more than one system ?
- How to find record using any key-value pair information of record in your local/custom database using Node.js ?
- Nodejs | authentication using Passportjs and passport-local-mongoose
- PHP | Determining Client IP Address
- How to identify server IP address in PHP ?
- HTML | DOM Local Storage clear() Method
- HTML | <input type="datetime-local">
- Local File Inclusion (LFI)
- Node.js | Local Module
- Golang Program that uses func as Local Variable
- Getting the current date and time with timestamp in local and other timezones in Golang
- How to add records in your own local/custom database in Node.js ?
- How to add unique Id to each record in your local/custom database in Node.js ?
- How to find record by Id from local/custom database in Node.js ?
- How to update a record in your local/custom database in Node.js?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.