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
ipandifconfigand 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
eth0orenp0s3. "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.cominto an IP address - iproute2 / net-tools: iproute2 is the package that provides
ip. net-tools is the older package that providesifconfig
Quick Summary
- To see IP addresses, use
ip a(the successor toifconfig) - Troubleshoot bottom-up: link → IP → route → reachability → name resolution
ifconfig: command not founddoes not mean something is broken. Just useip
Assumptions
- OS: Ubuntu / RHEL-family or any common Linux
iproute2(theipcommand) is installed by default- Some commands need
sudoor 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 beenp0s3etc.)inet 192.168.1.20/24— the assigned IPv4 address. The trailing/24is the subnet size; here192.168.1.0–192.168.1.255form one networkUP— the interface is enabled by the OSLOWER_UP— the physical link is connected
To inspect one interface only:
$ ip addr show eth0
The ifconfig equivalent:
$ ifconfig $ ifconfig eth0
How do you check link state?
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 DOWNmeans 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
ip link set ... down can cut your own connection
Never take down the interface you are working through while connected over SSH. The session drops immediately. On a host you can only reach over SSH, you cannot bring it back yourself.
The safe way
- Before touching anything, run
ip route get <your client IP>to identify the interface your SSH session uses, and leave that interface alone - If you must change it, schedule the rollback first, independently of your session. Note that bringing the link back
upmay not be enough: taking itdowndrops the routes through that interface, the default route included, andupdoes not restore them. Schedule a re-apply of the network configuration instead- NetworkManager:
sudo systemd-run --on-active=60 /bin/sh -c 'nmcli networking off; nmcli networking on' - systemd-networkd:
sudo systemd-run --on-active=60 /bin/sh -c 'systemctl restart systemd-networkd' - netplan:
sudo systemd-run --on-active=60 /bin/sh -c 'netplan apply' - Without systemd:
echo 'netplan apply' | at now + 1 minuteor similar
- NetworkManager:
- Confirm you can reach a console (IPMI, or your cloud provider's serial console) before you start
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.8OK butexample.comfails — 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.
- Link:
ip link show— is itstate UP? - IP:
ip a— is an address assigned? - Route:
ip route— is there adefault via ...? - Reachability:
ping -c 4 <gateway>→ping -c 4 8.8.8.8 - Name resolution: if
ping -c 4 example.comfails, 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 ... downover 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.