Network Commands Basics: Checking Connectivity with ip and ifconfig

Network Commands Basics: Checking Connectivity with ip and ifconfig

What you'll be able to do

  • Check your own connectivity with `ip a`, `ip link`, and `ip route`
  • Isolate a "no network" problem in order: link → IP → route → reachability → DNS
  • Translate legacy commands such as `ifconfig` into `ip` / `ss` equivalents

Prerequisites (read these first)

What You'll Learn

  • The difference between ip and ifconfig and when to use each
  • How to isolate "no network" issues layer by layer
  • A repeatable routine for checking IP, link, route, and reachability

Terms used in this article (defined up front)

  • Interface: the device that traffic enters and leaves through. It gets a name such as eth0 or enp0s3. "NIC" and "network adapter" mean the same thing
  • Link: the physical-level state — whether a cable or wireless connection is actually up. Also called "layer 1" or "the physical layer"
  • Route (routing): the path that decides where data is sent next. "Route table" and "routing table" refer to the same thing
  • Default gateway: the device your traffic leaves through when the destination is outside your own network. In most setups this is the router
  • Reachability: whether packets actually arrive at the target
  • Name resolution (DNS): the mechanism that turns a name such as example.com into an IP address
  • iproute2 / net-tools: iproute2 is the package that provides ip. net-tools is the older package that provides ifconfig

Quick Summary

  • To see IP addresses, use ip a (the successor to ifconfig)
  • Troubleshoot bottom-up: link → IP → route → reachability → name resolution
  • ifconfig: command not found does not mean something is broken. Just use ip

Assumptions

  • OS: Ubuntu / RHEL-family or any common Linux
  • iproute2 (the ip command) is installed by default
  • Some commands need sudo or admin privileges

How do ip and ifconfig differ?

ifconfig ships with the legacy net-tools package. It is now deprecated, and on many new systems it is not installed at all. Its successor is ip, from the iproute2 package. ip handles IP addresses, links, and routes in a single tool. Use ip on modern systems.

Aspect ifconfig (net-tools) ip (iproute2)
Status Deprecated, unmaintained Current, recommended
Installed by default Often absent on modern systems Standard
Scope IP and link only IP, link, route, more
Multiple/sub IPs Incomplete display Displayed correctly

ifconfig: command not found is not a fault. net-tools simply is not installed. You can run sudo apt install net-tools, but using ip is the proper approach.

How do you check an IP address?

Run ip a to list IP addresses on every interface. ip a is short for ip addr show. If you are used to net-tools, bare ifconfig shows the same data. Start here to learn your own IP.

$ ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
    inet 192.168.1.20/24 brd 192.168.1.255 scope global eth0

What to read:

  • eth0 — interface name (may be enp0s3 etc.)
  • inet 192.168.1.20/24 — the assigned IPv4 address. The trailing /24 is the subnet size; here 192.168.1.0192.168.1.255 form one network
  • UP — the interface is enabled by the OS
  • LOWER_UP — the physical link is connected

To inspect one interface only:

$ ip addr show eth0

The ifconfig equivalent:

$ ifconfig
$ ifconfig eth0

Use ip link to check the link state. Two things matter here: whether the cable is connected, and whether the interface is enabled. Even with an IP assigned, state DOWN means no traffic flows. Check this first when "nothing connects."

$ ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP ...
  • state UP — link enabled. state DOWN means disabled
  • No LOWER_UP — suspect an unplugged cable or the peer device

Bring an interface up or down manually (needs admin rights):

$ sudo ip link set eth0 up
$ sudo ip link set eth0 down

How do you check the routing table?

Run ip route to see the default gateway and the route table. Even with a correct IP, no gateway means no outbound traffic. This is the classic check when the LAN works but the internet does not.

$ ip route
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.20
  • default via 192.168.1.1 — the default gateway. No default = no outbound
  • Line 2 — same-subnet destinations are delivered directly

To resolve the route to a specific destination, ip route get is handy:

$ ip route get 8.8.8.8

How do you test reachability?

Use ping to verify that packets actually reach a target. -c sets how many packets to send; without it, ping keeps going forever. Try gateway → external IP → domain name in that order. That order pinpoints where the path breaks.

$ ping -c 4 192.168.1.1
$ ping -c 4 8.8.8.8
$ ping -c 4 example.com

How to read it:

  • Gateway unreachable — a link or route problem (go back to ip link / ip route)
  • 8.8.8.8 OK but example.com fails — a name resolution (DNS) problem
  • All fail — suspect routing, a firewall, or the ISP side

100% packet loss does not always mean the network is broken. The peer may simply block ICMP, the traffic type ping uses. When the target is a web server, also run curl -I https://example.com to check reachability at the HTTP level.

How do you isolate a "no connection" issue?

Clear the layers from the bottom up. Go link → IP → route → reachability → name resolution. The first layer that fails is the cause. Starting from the top wastes time.

  1. Link: ip link show — is it state UP?
  2. IP: ip a — is an address assigned?
  3. Route: ip route — is there a default via ...?
  4. Reachability: ping -c 4 <gateway>ping -c 4 8.8.8.8
  5. Name resolution: if ping -c 4 example.com fails, suspect DNS
# One command at a time, top to bottom
ip link show
ip a
ip route
ping -c 4 8.8.8.8
ping -c 4 example.com

Common mistakes

  • Pinging a domain name first and declaring "the network is dead" (it is only DNS)
  • Seeing an IP assigned, relaxing, and missing a missing gateway
  • Running ip link set ... down over SSH and cutting your own session

Old-to-new command cheat sheet

Even if you know ifconfig / route / netstat, learning the ip / ss equivalents makes the migration painless. Keep this table at hand. ss is the successor to netstat and also comes from iproute2.

Task Old (net-tools) New (iproute2)
Show IP addresses ifconfig ip a
Bring link up ifconfig eth0 up ip link set eth0 up
Show route table route -n ip route
ARP table arp -n ip neigh
Listening ports netstat -tlnp ss -tlnp
# Copy-paste: quick status snapshot
ip -br a && ip route && ss -tlnp

ip -br a (-br = brief) prints each interface and IP on one line. Ideal for a quick overview.

Next Steps

Share this article