Network Commands Basics: Checking Connectivity with ip and ifconfig

Network Commands Basics: Checking Connectivity with ip and ifconfig

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

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 and is now deprecated. ip, from the newer iproute2 package, handles IP addresses, links, and routes in one 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 (short for ip addr show) to list IP addresses on every interface. If you prefer 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 — assigned IPv4 address and subnet
  • UP / LOWER_UP — logically up / physical link present

To inspect one interface only:

$ ip addr show eth0

The ifconfig equivalent:

$ ifconfig
$ ifconfig eth0

Use ip link to check cable connection and whether an interface is enabled (the physical layer). Even with an IP assigned, state DOWN means no traffic. 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

Setting your working interface down while connected over SSH drops the session immediately and you cannot recover it. Be especially careful on production hosts with no console access.

How do you check the routing table?

Run ip route to see the default gateway and 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 packets actually reach a target; -c limits the count so it stops. Try gateway → external IP → domain name in order to pinpoint 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 may simply mean the peer blocks ICMP. For a web server, also check HTTP-level reachability with curl -I https://example.com.

How do you isolate a "no connection" issue?

Clear 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.

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