Linux Networking Commands Explained: ip, ss, ping and Reading Your Own Network


When the internet stops working on a Linux machine, most people start rebooting things at random. There is a better way: three built-in commands will tell you exactly where the problem is.

Start with ip: what is my machine connected to

The old ifconfig command is retired. Its replacement is ip, and it is more powerful:

ip addr show

This lists every network interface, its IP address and its state. Look for state UP — an interface that says DOWN is not connected at all.

To see how your machine reaches the internet, check the route table:

ip route

The line starting with default is your gateway — usually your router. If there is no default route, your machine does not know where to send traffic, and that is your problem.

Then ss: who is listening and talking

ss (socket statistics) replaces the old netstat. It shows which programs are using the network:

ss -tuln

This lists listening TCP and UDP ports. It is the fastest way to answer “is my web server actually running?” If your service is not in this list, it is not listening — check whether it started, not whether the firewall is blocking it.

To see live connections:

ss -tun state established

This shows every active connection, which is genuinely useful when you are wondering what your machine is talking to.

Then ping: is the other end reachable

ping sends small test packets and measures the reply:

ping -c 4 8.8.8.8

If this works but ping -c 4 google.com fails, your internet connection is fine and the problem is DNS — your machine cannot turn names into addresses. That distinction saves a lot of wasted troubleshooting.

A quick diagnostic order that works almost every time:

  • ip addr show — do I have an address?
  • ip route — do I have a gateway?
  • ping -c 4 <gateway> — can I reach my router?
  • ping -c 4 8.8.8.8 — can I reach the internet?
  • ping -c 4 google.com — does DNS work?

The first step that fails tells you where the fault is. Everything before it is fine.

Two more commands worth knowing

  • traceroute google.com shows every hop between you and the destination, so you can see exactly where packets stop.
  • dig google.com queries DNS directly and shows you the raw answer, which settles “is it DNS or is it the site?” arguments instantly.

The security angle

These same commands are how you spot something wrong. An unfamiliar listening port in ss -tuln, or a connection to an address you do not recognise in ss -tun state established, deserves a closer look. Knowing your machine’s normal network behaviour is the simplest form of intrusion detection there is — and it costs nothing.

Only run these commands on machines you own or administer. They are diagnostic tools, not a licence to probe other people’s networks.

Comments

Popular Posts