IP Check on Linux: curl vs iproute2 for Checking Network and IP Configuration

Use iproute2 first for local Linux network facts, and use curl when you need to know what the outside internet sees. That simple split saves time. iproute2 replaced older tools like ifconfig and route on modern Linux systems, with the ip command becoming the standard interface for addresses, routes, and links [source: man7].

TLDR: Use ip addr and ip route for local network setup, such as your NIC IP, gateway, and route table. Use curl for public IP checks, such as curl https://api.ipify.org. In a quick help desk check, this can cut a 5 minute “why is the server offline?” guess into a 30 second test: local IP, default route, public IP. If ip route looks right but curl shows the wrong public address, suspect NAT, VPN, proxy, or cloud routing.

What each tool is really checking

curl and iproute2 both help with IP checks, but they answer different questions. That difference matters.

  • iproute2 shows what Linux knows locally. It reads kernel network state.
  • curl talks to a remote web service. It shows how your traffic appears from the internet side.

Honestly, it feels like half of Linux network confusion comes from mixing those two views. Your server can have a correct private IP and still appear online through a different public IP. Or it can have a public IP response through curl while the local interface setup is a mess.

Use iproute2 to inspect local IP configuration

The main command is ip. It is part of iproute2, and it gives you a clean view of interfaces, addresses, routes, and link state.

Start with this:

  • ip addr show — shows all network interfaces and IP addresses.
  • ip -brief addr — gives a shorter, cleaner output.
  • ip link show — checks whether interfaces are up or down.
  • ip route — shows routing rules and the default gateway.
  • ip route get 1.1.1.1 — shows which interface and source IP Linux will use to reach that address.

That last command is underrated. If a machine has several interfaces, VLANs, VPNs, or containers, ip route get can tell you the path Linux will actually pick. No guessing. No squinting at a huge route table.

Example:

ip route get 8.8.8.8

You might see a result showing via 192.168.1.1 dev eth0 src 192.168.1.40. This tells you the gateway, the device, and the source IP. That is useful when troubleshooting servers, laptops, and cloud instances.

Use curl to check your public IP

curl is best when you want the external view. It asks a remote service, “What IP did this request come from?”

Common examples:

  • curl https://api.ipify.org
  • curl https://ifconfig.me
  • curl https://icanhazip.com
  • curl -4 https://ifconfig.co for IPv4 only
  • curl -6 https://ifconfig.co for IPv6 only

This is perfect for checking NAT, VPN exits, cloud egress IPs, and firewall allowlists. For example, if a SaaS vendor asks you to allowlist your office IP, curl https://api.ipify.org gives the address they are likely to see.

The catch is that curl depends on outside services. If DNS is broken, HTTPS is blocked, or the service is down, your result may be useless. Expect to waste time if you treat one failed curl response as proof that your Linux networking is broken.

curl vs iproute2: quick comparison

  • Best for local IP: ip addr
  • Best for gateway checks: ip route
  • Best for public IP: curl
  • Works without internet: iproute2
  • Shows NAT result: curl
  • Shows interface state: ip link

For business networks, the right check depends on where the fault sits. If teams are dealing with cloud links, remote workers, SD WAN, or ISP issues, the split between private and public addressing becomes even more useful. Many of the same ideas show up in wider telecommunication and networking trends, where visibility matters more than pretty diagrams.

A practical troubleshooting flow

When a Linux host “has no internet,” do not start with random package reinstalls. Check in layers.

  1. Check interface status: ip -brief link
  2. Check local IP: ip -brief addr
  3. Check default route: ip route
  4. Check path selection: ip route get 1.1.1.1
  5. Check public IP: curl https://api.ipify.org
  6. Check IPv6 separately: curl -6 https://ifconfig.co

If step 2 fails, the machine may not have an IP. If step 3 fails, there may be no gateway. If step 5 fails but the route looks good, test DNS, firewall rules, proxy settings, or outbound access.

This flow is also useful for learning. If you want to get better at Linux networking, join technical communities, read real troubleshooting threads, and save working command examples. Good mailing lists for learning and professional growth can be surprisingly helpful because people post messy, real problems.

Common mistakes

  • Using only curl: It will not show your local subnet, gateway, or inactive NIC.
  • Using only ip addr: It will not tell you the public IP seen by websites.
  • Forgetting VPNs: VPNs often change the public IP and route path.
  • Ignoring IPv6: Some failures happen only on IPv6 or only on IPv4.
  • Trusting one IP service: Try two services if the result looks odd.

Best simple command set

Keep this set handy:

  • ip -brief addr
  • ip route
  • ip route get 1.1.1.1
  • curl https://api.ipify.org
  • curl -4 https://ifconfig.co
  • curl -6 https://ifconfig.co

The best answer is not curl or iproute2. It is both. Use iproute2 to understand the machine. Use curl to understand how the outside world sees it. That pairing gives you the fastest route from “network is broken” to a real fix.

You May Also Like