Amazon holiday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Linux Get IP Address Without ifconfig: Commands That Work

Yes. On most Linux systems, run ip addr to see IP addresses assigned to network interfaces; hostname -I is a shorter alternative. The ip command is the standard modern replacement for ifconfig, which is often not installed by default.

Quick commands to find your Linux IP address

Open a terminal and choose a command based on the address you need. These commands normally work without administrator privileges because they only read network configuration.

  • ip addr shows addresses, interfaces, and interface state.
  • ip -4 addr shows only IPv4 addresses.
  • ip -6 addr shows only IPv6 addresses.
  • hostname -I prints assigned IP addresses in a compact line.
  • ip -br addr gives a brief, easier-to-scan interface summary.

In the output of ip addr, look for a line beginning with inet for IPv4 or inet6 for IPv6. For example, inet 192.168.1.24/24 means the interface has the IPv4 address 192.168.1.24. The /24 is the network prefix length, not part of the address itself.

Why ifconfig may be missing

ifconfig belongs to the older net-tools package. Many current Linux distributions do not install that package by default, so typing ifconfig can produce a “command not found” message. This does not mean the computer has no network connection; it usually means only that the older utility is absent.

The ip command comes from the iproute2 tools, which are the usual way to inspect and manage networking on modern Linux systems. It covers more than address display, including routes and links, and its output includes details that older commands may present differently. If ip is also missing, install the appropriate package for your distribution or use a desktop network settings panel. Package names and installation commands can vary, but common names include iproute2 on Debian-based systems and iproute on Fedora-based systems.

Choose the address you actually need

A machine can have several IP addresses at once. It may have a wired interface, Wi-Fi, a VPN, virtual machine or container interfaces, and the loopback interface. Each can have its own address. Therefore, seeing multiple results is normal; the useful one depends on what you are trying to do.

  • For another device on your local network: use the IPv4 or IPv6 address on the active Wi-Fi or Ethernet interface. A private IPv4 address often begins with 10., 192.168., or 172.16 through 172.31.
  • For a particular network protocol: use ip -4 addr or ip -6 addr to avoid mixing address families.
  • For a connection over a VPN: check the VPN interface as well as the ordinary network interface; traffic to some destinations may use the VPN address.
  • For a local program on the same computer: 127.0.0.1 (IPv4) or ::1 (IPv6) is loopback. Other computers cannot use that address to reach your machine.

Addresses beginning with 169.254. are IPv4 link-local addresses, typically used when a device has not obtained an ordinary IPv4 configuration. An inet6 address beginning with fe80:: is link-local IPv6 and is generally usable only on its local network segment. These addresses are real, but they are not interchangeable with a routable address for every purpose.

Read ip addr output and identify an interface

Run ip addr and find the interface that carries the connection you care about. Names such as enp2s0 or eth0 commonly indicate wired networking, while names such as wlp3s0 or wlan0 commonly indicate Wi-Fi. Naming conventions vary, so treat the name as a clue rather than a guarantee. The lo interface is loopback and is not your connection to the LAN.

To focus on one interface, substitute its actual name in this command:

ip -4 addr show dev wlp3s0

In the output, state UP indicates that the interface is administratively enabled, while LOWER_UP generally indicates that the underlying link is present. An address marked dynamic is commonly assigned automatically, for example through DHCP; it can change later. A command such as ip -br addr is useful when the full detail is distracting, but use the longer output when you need to see address scope or interface flags.

Check which address Linux uses for a destination

If you want the source address used for a particular outgoing connection, a route lookup is often more informative than scanning every interface. Try ip route get 1.1.1.1. Linux prints the route it would use to reach that destination; look for fields such as dev for the interface and src for the selected source address. For an IPv6 route lookup, use an IPv6 destination, such as ip -6 route get 2606:4700:4700::1111.

This is a routing-table lookup, not a test that the destination is reachable. It can identify the address Linux would select even if the internet connection is down. Also, the result may differ for another destination if your system has multiple routes, policy routing, or a VPN. To see configured routes and the default gateway, use ip route; for IPv6 routes, use ip -6 route. The gateway is the next-hop router, not the computer’s own IP address.

Find your public IP address

The address shown by ip addr is assigned to a local interface. On a typical home network, that is a private address behind a router, not the public address that an internet service sees. To ask an external service what public IPv4 address your connection appears to use, you can run curl -4 https://api.ipify.org. If curl is installed and the request succeeds, the service returns an address as seen from its end. For IPv6, try curl -6 https://api.ipify.org; this works only when your system and network have IPv6 connectivity.

This method depends on an outside service and reports the public egress address for that request. A VPN, corporate proxy, carrier-grade NAT, or network gateway can affect the result. If a router shares one public address among several devices, the public result will not tell you which private address your Linux computer has. Use a service you trust, and avoid sending requests to unfamiliar sites just to check an address.

Other tools and when to use them

There are alternatives when you want a graphical view or when your system is managed by a particular networking service. They may not be available on every distribution, and they can show different kinds of information.

  • nmcli device show displays detailed device information on systems using NetworkManager. Filter or inspect the output for fields such as IP4.ADDRESS and IP6.ADDRESS.
  • networkctl status can show link and address details on systems managed by systemd-networkd.
  • A desktop environment’s network settings usually shows the address for the selected Wi-Fi or wired connection. This is convenient, though less useful for remote servers without a graphical interface.
  • ifconfig can still be installed from the distribution’s legacy net-tools package if a script or familiar workflow requires it. For new troubleshooting, learning ip is generally more useful.

These tools are not identical. NetworkManager commands report information from NetworkManager, while ip reports the kernel’s current networking state. If their output seems inconsistent, first confirm the interface name, whether the connection has just changed, and whether you are looking at a VPN, container, or virtual interface.

Common problems and useful checks

  • There is no inet address. Check that the interface is up and connected. For Wi-Fi, confirm that you joined the intended network; for Ethernet, check the cable and link. If automatic configuration is expected, reconnect or inspect the network manager’s status.
  • The output has many addresses. Use ip -4 addr, ip -6 addr, or ip -4 addr show dev INTERFACE to narrow it down. Do not assume the first address printed is the one applications use.
  • You found 127.0.0.1. That is the IPv4 loopback address. Look at a connected network interface for an address reachable from other devices.
  • You found an address but cannot connect to it. An address alone does not prove that a service is listening or that a firewall permits access. Check the service, firewall rules, routing, and whether the address is reachable from the other device’s network.
  • A command works locally but not in a container. Containers and network namespaces can have separate interfaces and addresses. Run the command in the same environment as the application whose connectivity you are troubleshooting.

Most address-inspection commands do not change the network configuration, so they are safe to run while diagnosing a connection. Be more careful with commands that modify addresses, routes, or interface state: a mistaken change on a remote machine can interrupt your session. For a basic lookup, there is no need to use sudo.

Frequently Asked Questions

What is the simplest command to see my Linux IP?
hostname -I prints assigned addresses compactly. For more detail and interface names, use ip addr.

How do I show only the IPv4 address?
Run ip -4 addr. To show IPv4 addresses for one interface, add show dev INTERFACE, replacing INTERFACE with its name.

Is ip addr the same as ifconfig?
They can both display interface addresses, but they are different utilities. ip is the modern iproute2 tool and also handles routes and links; ifconfig is part of older net-tools.

Does hostname -I show my public IP?
Usually not. It prints addresses assigned locally to the host. To check the public address seen by the internet, query a trusted external service, keeping in mind that a VPN or proxy may change the result.

Why does my Linux computer have more than one IP address?
It may have multiple interfaces, IPv4 and IPv6 addresses, VPN or virtual interfaces, or more than one address on a single interface. Identify the interface and address family that match your use case.

Linux Get IP Address Without ifconfig: Commands That Work
Scroll to top