0
0
Linux-cliHow-ToBeginner · 3 min read

How to Check IP Address on Linux: Simple Commands

To check your IP address on Linux, use the ip addr show command to display all network interfaces and their IPs. Alternatively, ifconfig can be used on some systems to show IP addresses assigned to interfaces.
📐

Syntax

The main commands to check IP addresses on Linux are:

  • ip addr show: Shows all network interfaces and their IP addresses.
  • ifconfig: Displays network interfaces and IPs (may require installation on some systems).

Use ip addr show [interface] to see IP for a specific interface like eth0 or wlan0.

bash
ip addr show

ifconfig
💻

Example

This example shows how to use ip addr show to find your IP address on all interfaces.

bash
ip addr show
Output
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 01:23:45:67:89:ab brd ff:ff:ff:ff:ff:ff inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic eth0 valid_lft 86398sec preferred_lft 86398sec inet6 fe80::1234:5678:9abc:def0/64 scope link valid_lft forever preferred_lft forever
⚠️

Common Pitfalls

Some common mistakes when checking IP addresses on Linux include:

  • Using ifconfig on systems where it is not installed by default (modern Linux prefers ip command).
  • Not running commands with sufficient permissions if needed (usually not required for just viewing IP).
  • Confusing IPv4 and IPv6 addresses; IPv4 looks like 192.168.x.x, IPv6 looks longer with colons.
bash
ifconfig

# If 'ifconfig' is not found, install net-tools or use 'ip addr show' instead
📊

Quick Reference

CommandDescription
ip addr showShow all network interfaces and IP addresses
ip addr show eth0Show IP address for interface eth0
ifconfigShow network interfaces and IPs (may require installation)
hostname -IShow all assigned IP addresses in a simple list

Key Takeaways

Use 'ip addr show' to reliably check IP addresses on modern Linux systems.
'ifconfig' may not be installed by default; prefer 'ip' command.
IPv4 addresses look like '192.168.x.x', IPv6 addresses contain colons.
You can specify an interface with 'ip addr show [interface]' to see its IP.
'hostname -I' gives a quick list of all IP addresses assigned to the machine.