An IP address (Internet Protocol Address) on a Linux LAN is a unique numeric identifier assigned to a device (computer, router) to identify and locate it on the network. All devices on a LAN must have a unique IP address so that they can communicate with each other and transfer data.
An IP on a LAN in Linux is represented in either IPv4 or IPv6 format. An IPv4 address consists of 4 numbers (0-255) separated by dots (e.g. 192.168.0.1). An IPv6 address consists of 8 groups of 4 hexadecimal digits separated by colons (e.g., 2001:0db8:85a3:0000:0000:0000:8a2e:0370:7334). It can be static, when it is manually assigned by the administrator, or dynamic, when it is assigned automatically using the Dynamic Host Configuration Protocol (DHCP).
There are several ways to find out the IP address on a local network in Linux.
Use the command:
ifconfig
The output of the command will show information about the network interfaces, including their IP addresses.
Use ip
:
ip addr show
The output of the command will also show information about network interfaces and their IP addresses.
Use hostname with the -I
key:
hostname -I
The -I
key allows you to get all the IP addresses associated with your host.
You can also apply nslookup
with a parameter specifying the DNS name of the host:
nslookup <host_name>
This will retrieve the IP address associated with the specified host DNS name.
nmap
will also work:
nmap -sn <IP range>
The nmap
command allows you to scan IP addresses in a given range and determine their availability on the network. It also outputs the IP addresses of devices on the local network.