How To Find IP Address In Linux (Ubuntu, Debian, Mint, CentOS)?

The IP address is the core of the computer networks where we use an IP address in our daily life regularly. When we try to access a web page or a game or a video stream the remote server IP address is used to connect and data transfer.

IP Address Types

IP is a protocol designed to be used in different network environments and provides different IP addressing scheme. One of the most popular IP address types are Public IP Address and Private IP Address.

  • Public IP Address is used inside the internet between clients, servers, modems, routers, etc. It can be also called as MAN or WAN specific IP address.
  • Private IP Address is used inside the local network or LAN. It is mainly used to access the gateway of the local network and does not use on the internet. Generally, the internet gateway will use its own Public IP Address for transmission over the internet. Also, WiFi, Routers, and modems provide private IP addresses to the LAN clients. The public IP address range is 10.0.0.-, and

Find IP Address with ifconfig Command

The ifconfig was the most popular network configuration command provided by all major Linux distributions. But recently it is replaced with the ip commands described below. The ifconfig command can be used to print Private IP address. We will provide the -a parameter which will print the IP addresses assigned to the interfaces.

$ ifconfig -a

Find IP Address with ip address Command

The ip address command is a defacto command used to display and manage network-related information like IP address, Default gateway, etc. The “ip address” command can be used to print the private IP address of the current Linux system.

$ ip address

In a more practical way the address can be shortened as add even a .

$ ip add

$ ip a

Find IP Address with ip route Command

The ip route command is used to display and manage IP routing table. But it can be also used to find private IP address of the Linux system. In order to print IP address we will try to list a route that doesn’t exist which will print the current IP address.

$ ip route get | awk '{print $7}'

Find IP Address with hostname Command

The hostname command is used to print host-related information like hostname, computer name, and of course IP address. The hostname command will print the private IP address of the current system. We will also provide the -I parameter.

$ hostname -I

The first IP address is the system IP address but it can be also displayed clearly like below by using the awk command to filter the default gateway IP address which is the second IP address.

$ hostname -I | awk '{print $1}'
Find IP Address with hostname Command

Find IP Address with host Command

The host command is a simple tool in order to make DNS queries and similar to the dig command it can be used to find public IP address. We will use the name servers like below.

$ host

The output is like below.

Using domain server:
Aliases: has address
Host not found: 3(NXDOMAIN)
Host not found: 3(NXDOMAIN)

Find IP Address with curl From Command Line

The curl command is used to make requests to the remote URLs via the command line. The curl name comes from “Command Line URL”. The curl command can be used to find the public IP address of the Linux system. There are different web sites on the internet which returns the IP address of the client via HTTP or similar protocols. The curl command can be used to display this public IP address via the command line.

$ curl
$ curl

By default, the returned IP address will be IPv4 but also if it is enabled and used the IPv6 public IP address can be displayed with the following commands. We will provide the -6 parameter to the curl command in order to use the IPv6 protocol.

$ curl -6

Find IP Address with wget From Command Line

The wget is a popular command line tool used to download files for different protocols. Similar to the curl command some web sites provides the service which returns our public IP address. We will use domain to return public IP address.

$ wget -O - -q

Alternatively use following wget command.

$ wget -qO-

Find IP Address with dig From Command Line

The dig command is used to find DNS related information like IP to domain name translation or domain name to IP translation. It can be also used to print the public IP address by using the DNS servers. The +short parameter will be provided for the to be resolved at .

$ dig +short

Find IP Address From XFCE Network Manager

The XFCE is a popular Linux desktop environment which provides the network information from the status bar like below. First click to the Network Icon like below. Then a menu will be opened where we will click to the Connection Information.

Open XFCE Network Information

The Connection Information screen provides general information like private IP address, Subnet Mask, Default route etc. By default the IPv4 will be displayed but if enabled the IPv6 will be displayed like below too.

XFCE IP Address (IPv4,IPv6)
See also  How To Set Timeout For Curl Command?

Leave a Comment