Complete Linux Networking Tutorials for Beginners to Advanced
A comprehensive Linux networking guide covering IP addressing, DNS, firewalling, TCP/UDP, troubleshooting, and secure file transfer with practical real-world examples.
1. IP Addressing in Linux
What is an IP Address?
An IP address is a unique identifier assigned to every device on a network.
Check IP Address
or
Assign Temporary IP Address
(Works until reboot)
sudo ip addr add 192.168.1.50/24 dev ens33
Bring Interface Up/Down
sudo ip link set ens33 up
sudo ip link set ens33 down
View Routing Table
Add Default Gateway
sudo ip route add default via 192.168.1.1
2. DNS and Host Resolution
Key Files
| FilePurpose |
/etc/hosts | Manual local name resolution |
/etc/resolv.conf | DNS server configuration |
/etc/nsswitch.conf | Order of name resolution |
Check DNS Resolution
nslookup google.com
dig google.com
host google.com
Add a Local Host Entry
echo "192.168.1.30 dbserver" | sudo tee -a /etc/hosts
Set DNS Servers
sudo nano /etc/resolv.conf
Add:
nameserver 8.8.8.8
nameserver 1.1.1.1
3. firewalld and iptables
firewalld (RHEL/CentOS/Fedora)
Check Firewall Status
sudo systemctl status firewalld
List Rules
sudo firewall-cmd --list-all
Open a Port (Example: 80)
Temporary:
sudo firewall-cmd --add-port=80/tcp
Permanent:
sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --reload
Service-Based Allow
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
iptables (Legacy Firewall)
View Current Rules
Allow SSH
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
Block an IP
sudo iptables -A INPUT -s 10.0.0.5 -j DROP
4. TCP/UDP Basics
Difference
| TCPUDP |
| Reliable | Unreliable |
| Connection-oriented | Connectionless |
| Slower | Faster |
| Used by SSH/HTTP/FTP | Used by DNS/NTP/VoIP |
Check Listening Ports
Breakdown:
t = TCPu = UDPl = Listeningn = Numericp = Show process
Check Connectivity
5. Network Troubleshooting Commands
Ping a Host
Trace Path to Server
Check ARP Table
Check Network Stats
Check Interface Statistics
Test DNS Resolution
Check Connectivity Using curl
curl -I https://google.com
Test Port Connectivity
6. SFTP, SCP, and FTPS
SFTP (SSH File Transfer Protocol)
Connect Using SFTP
Download File
Upload File
SCP (Secure Copy)
Copy File to Server
scp test.txt user@192.168.1.20:/tmp/
Copy File From Server
scp user@192.168.1.20:/var/log/messages .
Copy Entire Directory
scp -r /data user@192.168.1.20:/backup/
FTPS (FTP over SSL/TLS)
Install FTP Client
Connect
lftp -u user,pass ftps://192.168.1.10
Upload a File
Download File