Skip to Content

3 ways to Find IP address in Ubuntu terminal

3 ways to Find IP address in Ubuntu terminal

If you’re using Ubuntu, you may need to know how to find your machine’s IP address. Here are three ways to do it.

First, you can use the “ip addr” command. Second, you can use the “ifconfig” command. Third, you can use the “curl” command.

Whichever method you choose, you should be able to find your IP address in no time!

In this article, I will share a few examples of using these commands to get ip address.

https://www.howtouseubuntu.com/network/ubuntu-command-terminal-find-ip-address-in-ubuntu/

what is ip address?

An IP address (Internet Protocol Address) is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It serves two principal functions: host or network interface identification and location addressing.

An IP address is assigned to each device on a network, such as a laptop, desktop, smartphone, printer or router, and it allows other devices on the same network to locate and communicate with that device.

IP addresses are used in communication between different machines across the internet or local networks.

The IP address is typically assigned by an Internet Service Provider (ISP) or a network administrator.

IP addresses are divided into two categories: private IP addresses and public IP addresses.

Private IP addresses are used within a local network and are not accessible from the internet, while public IP addresses are unique, identifiable addresses that can be accessed from the internet.

Find your ip address in Ubuntu using ip add command

The easiest way to find your IP Address in Ubuntu is by using the ip add command. The first step is to open a terminal window and type in ip addr followed by pressing enter. This will display detailed information about each interface on the system. Look for the line that shows inet. The IP address is listed next to inet.

the ip command is installed by default in most distributions of Linux, including Ubuntu. It is part of the iproute2 suite.

I find this command very helpful for troubleshooting network issues or for configuring network settings.

The ip addr command provides a lot of information and options, making it a very powerful tool for managing our network interfaces in Ubuntu Linux.

In addition to showing the IP address, it also displays the status of the network interface, the MAC address, the subnet mask, and many other details.

Here’s an example output of the ip addr command:

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 fq_codel state UP group default qlen 1000 link/ether 00:16:3e:4d:67:89 brd ff:ff:ff:ff:ff:ff 
inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0 valid_lft 86081sec preferred_lft 86081sec 
inet6 fe80::216:3eff:fe4d:6789/64 scope link noprefixroute valid_lft forever preferred_lft forever 

In this example, the IP address is 192.168.1.100.

We can also type ip address or ip a for short.

  • ip addr – Show IP address for all interfaces
  • ip addr show dev em1 – Display information only for device em1
  • ip addr show up – Show IP address for the running interfaces

Here are the detailed steps to find the ip address in Ubuntu.

  1. Open a terminal window.
  2. Type the following command to list all network interfaces: ip addr
  3. Look for the interface that you want to find the IP address for (e.g., eth0 for a wired Ethernet connection, wlan0 for a wireless connection).
  4. Locate the line that starts with inet under the desired interface. The IP address is listed next to inet.

Find your ip address in Ubuntu using ifconfig command

In Ubuntu, you can use the ifconfig command to find your IP address. To do this, open a terminal and type the following command: ifconfig.

This command will display information about your network interfaces and their configuration. Look for the line that starts with “inet” under the section for your active network interface (usually eth0 or wlan0). The number next to “inet” is your IP address.

Here’s an example output of the ifconfig command:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::216:3eff:fe4d:6789 prefixlen 64 scopeid 0x20<link> ether 00:16:3e:4d:67:89 txqueuelen 1000 (Ethernet) RX packets 209715 bytes 263456789 (263.4 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 140120 bytes 161580321 (161.5 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

The IP address is 192.168.1.100 in this example.

The ifconfig command is considered outdated and is being phased out in favor of more modern network configuration tools like the ip command in recent versions of Ubuntu and other Linux distributions.

The ifconfig command is not installed by default in recent versions of Ubuntu.

If you need to use ifconfig, you can install it by running the following command:

sudo apt-get install net-tools

Find public IP address in Ubuntu Linux using curl command

All of the above are private IPs. Let’s see how to find out the public IP address.

To find your public IP address in Ubuntu Linux, you can use the curl command. This will make a request to a web server and return its public IP address. To do this, open a terminal window and type in:

curl ifconfig.me

This should display your public IP address on the screen. The output of this command might look something like this:

123.45.67.89

This is your public IP address.

In summary, finding your IP address in Ubuntu can be done using either the ip addr or ifconfig commands. If you need to find your public IP address, you can use the curl command.

All these commands are available in Ubuntu and most other Linux distributions. If you have any issues or questions about finding IP addresses in Ubuntu, please feel free to ask our experts for help.

sameri

Sunday 11th of June 2023

Cool. I got my IP address with ip addr command. Thanks.

Joey

Sunday 19th of February 2023

It is very helpful. I got my IP address with this guide. Thanks!