Complete Linux Networking Tutorials for Beginners to Advanced - Textnotes

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


ip addr show

or


ifconfig # Older tool

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


ip route show

Add Default Gateway


sudo ip route add default via 192.168.1.1

2. DNS and Host Resolution

Key Files

FilePurpose
/etc/hostsManual local name resolution
/etc/resolv.confDNS server configuration
/etc/nsswitch.confOrder 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


sudo iptables -L -n -v

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
ReliableUnreliable
Connection-orientedConnectionless
SlowerFaster
Used by SSH/HTTP/FTPUsed by DNS/NTP/VoIP

Check Listening Ports


sudo ss -tulnp

Breakdown:

  1. t = TCP
  2. u = UDP
  3. l = Listening
  4. n = Numeric
  5. p = Show process

Check Connectivity


nc -zv 192.168.1.20 22

5. Network Troubleshooting Commands

Ping a Host


ping -c 4 google.com

Trace Path to Server


traceroute google.com

Check ARP Table


arp -a

Check Network Stats


netstat -tuln

Check Interface Statistics


ip -s link

Test DNS Resolution


dig yahoo.com

Check Connectivity Using curl


curl -I https://google.com

Test Port Connectivity


telnet 192.168.1.10 3306

6. SFTP, SCP, and FTPS

SFTP (SSH File Transfer Protocol)

Connect Using SFTP


sftp user@192.168.1.20

Download File


get file.txt

Upload File


put report.pdf

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


sudo yum install lftp -y

Connect


lftp -u user,pass ftps://192.168.1.10

Upload a File


put backup.tar.gz

Download File


get data.zip