You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Linux has powerful built-in networking capabilities. Whether you are configuring a server, debugging connectivity issues, or securing a firewall, understanding Linux networking tools is essential.
A network interface is the point of connection between your system and a network. Common interface names:
| Name Pattern | Type |
|---|---|
| eth0, ens33 | Ethernet (wired) |
| wlan0, wlp2s0 | Wireless |
| lo | Loopback (localhost, 127.0.0.1) |
| docker0, br-xxx | Bridge (Docker, containers) |
| veth | Virtual Ethernet (containers) |
The ip command is the modern replacement for the older ifconfig:
ip addr show # show all interfaces and IP addresses
ip addr show eth0 # show specific interface
ip link show # show link-layer information
ip route show # show routing table
ip neigh show # show ARP table (neighbours)
# Temporary (lost on reboot)
sudo ip addr add 192.168.1.100/24 dev eth0
sudo ip link set eth0 up
# Permanent — depends on distribution
# Ubuntu/Debian: /etc/netplan/*.yaml
# Fedora/RHEL: /etc/NetworkManager/system-connections/
Example Netplan configuration (Ubuntu):
# /etc/netplan/01-config.yaml
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
sudo netplan apply # apply netplan configuration
ping google.com # ping continuously (Ctrl+C to stop)
ping -c 4 google.com # send 4 pings then stop
ping -c 4 192.168.1.1 # ping an IP address
traceroute google.com # show the route packets take
tracepath google.com # similar, no root required
mtr google.com # real-time traceroute with statistics
ss is the modern replacement for netstat:
ss -tuln # show TCP/UDP listening ports
ss -tulnp # include process names
ss -s # show socket summary statistics
ss -t state established # show established TCP connections
ss -t dst 10.0.0.5 # connections to a specific destination
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1234))
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=5678))
ESTAB 0 0 10.0.0.5:22 10.0.0.10:54321 users:(("sshd",pid=2345))
| Port | Service |
|---|---|
| 22 | SSH |
| 80 | HTTP |
| 443 | HTTPS |
| 53 | DNS |
| 25 / 587 | SMTP (email) |
| 3306 | MySQL |
| 5432 | PostgreSQL |
| 6379 | Redis |
| 8080 | HTTP (alternative) |
| 27017 | MongoDB |
dig google.com # detailed DNS query
dig google.com +short # show just the IP address
dig -x 142.250.187.206 # reverse DNS lookup
nslookup google.com # simpler DNS lookup
host google.com # another DNS lookup tool
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.