Linux Networking Essentials: From Basics to Advanced Tools

Sushant Gaurav
4 min readJan 2, 2025

Welcome back to our Linux learning series! In the last article (click here to read), we explored Linux file systems, permissions, etc. using examples. Today, we’ll dive into the Linux networking system, an essential part of understanding and using Linux effectively.

Networking is a critical part of any Linux system, whether you’re developing applications, working on cloud infrastructure, or troubleshooting connectivity issues. In this article, we’ll explore essential networking concepts and tools in Linux, complete with practical examples and diagrams to solidify your understanding.

1. Introduction to Networking in Linux

Networking in Linux involves managing how your system communicates with other devices over a network. Whether it’s through the internet or a local network, Linux offers powerful tools and configurations for seamless connectivity.

Why Networking is Crucial for Developers and Sysadmins

  • Developers: Test APIs, interact with servers, and configure local testing environments.
  • Cloud Engineers/DevOps: Manage server communication, secure remote access, and automate networking tasks.

2. Understanding IP Addresses, Subnetting, and Routing

IP Addresses

An IP address identifies devices on a network. Linux systems often use IPv4, which consists of four octets, e.g., 192.168.1.1.

Subnetting

Subnetting divides a network into smaller sub-networks, improving efficiency and security. Subnet masks, like 255.255.255.0, define how IP addresses are divided between the network and host parts.

Routing

Routing determines how data moves between devices on different networks. Linux systems maintain a routing table to decide the next hop for network traffic.

# View the routing table
route -n

3. Tools for Network Analysis

Linux comes equipped with several tools for analyzing and troubleshooting networks.

ping

Used to check connectivity between your system and another device.

ping -c 4 google.com

netstat

Displays network connections, routing tables, and interface statistics.

netstat -an

traceroute

Shows the path packets take to reach their destination.

traceroute google.com

curl

Transfers data from or to a server, ideal for API testing.

curl -I https://example.com

wget

Download files from the internet.

wget https://example.com/file.zip

4. Configuring Network Interfaces

Network interfaces in Linux can be configured using tools like ifconfig (older) or ip (modern).

Using ifconfig

# View all interfaces
ifconfig
# Assign an IP address
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up

Using ip

# View all interfaces
ip addr
# Assign an IP address
sudo ip addr add 192.168.1.100/24 dev eth0

5. SSH: Secure Remote Access

Secure Shell (SSH) allows you to connect to remote systems securely.

Setting Up SSH

  1. Install the SSH server:
sudo apt install openssh-server

2. Start and enable the SSH service:

sudo systemctl start ssh sudo systemctl enable ssh

3. Verify SSH is running:

sudo systemctl status ssh

Accessing a Remote System

ssh user@192.168.1.10

Tips for Secure SSH

  • Use SSH keys instead of passwords:
ssh-keygen -t rsa
ssh-copy-id user@192.168.1.10
  • Disable root login in /etc/ssh/sshd_config.
  • Change the default SSH port.

6. Practical Use Cases

Use Case 1: Troubleshooting Connectivity Issues

  1. Ping the destination to check connectivity.
ping -c 4 192.168.1.1

2. Use traceroute to find the issue along the network path.

traceroute 192.168.1.1

3. Check the routing table for incorrect entries.

route -n

Use Case 2: Automating SSH Workflows

Automate file backups to a remote server using rsync over SSH:

rsync -avz /path/to/files user@192.168.1.10:/remote/path

7. Example: Setting Up an SSH Server and Accessing It

Server Setup

  1. Install OpenSSH:
sudo apt install openssh-server

2. Configure SSH to use a non-default port:

sudo nano /etc/ssh/sshd_config Port 2222

Client Access

  1. Connect using the new port:
ssh -p 2222 user@192.168.1.10

2. Automate login with SSH keys:

ssh-keygen -t rsa
ssh-copy-id user@192.168.1.10
ssh user@192.168.1.10

8. Resources for Further Learning

Conclusion

This article covered the fundamentals of networking in Linux, from basic tools like ping and curl to advanced topics like SSH setup and network interface configuration. Understanding these tools and concepts is essential for anyone working in software development, cloud computing, or DevOps.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Sushant Gaurav
Sushant Gaurav

Written by Sushant Gaurav

A pragmatic programmer 👨🏻‍💻 with a sarcastic mind 😉 who loves travelling and food :)

No responses yet

Write a response