6. Linux Networking, DNS, SSH & Security Hardening

Modules 17-22: IP routing, DNS A/CNAME/PTR records, SSH key authentication, firewalld/UFW rules & SELinux enforcing mode

Module 1: Networking Fundamentals & Layered Troubleshooting

Configuring network interfaces, routing tables, DNS resolution, and firewalls.

🇬🇧 English Definition

Troubleshoot network issues layer by layer: interface link -> IP address -> gateway route -> DNS resolution -> firewall rules -> listening port -> application layer.

🇮🇳 Hinglish Definition

Network issue ko layer-by-layer troubleshoot karo; random commands run karna avoid karo.

Core Concepts & Rules

  • ip addr & ip route: Display IP configuration and routing table entries.
  • ss -tulpn: Shows listening TCP/UDP sockets and matching process names.
  • Default Gateway: Router interface used to reach subnets outside local network.

🔍 Line-by-Line Command Breakdown

  1. Line 1: ip addr displays network interface configuration.
  2. Line 2: ip route displays default gateway routing table.
  3. Line 3: ss -tulpn shows listening network ports and process PIDs.
  4. Line 4: traceroute example.com traces network hop path to destination.

🎯 Interview Focus & Questions

  • Q: TCP vs UDP?
    A: TCP is connection-oriented, reliable, and ordered; UDP is connectionless with lower overhead and no delivery guarantee.
  • Q: How to troubleshoot SSH failure?
    A: Check IP reachability (ping), routing, DNS if hostname is used, sshd status/port (ss -tulpn), firewall, and auth logs.
💻 Command Example & Terminal Output - Networking Fundamentals & Layered Troubleshooting
ip addr
ip route
ping -c 4 8.8.8.8
ss -tulpn
traceroute example.com
curl -I https://example.com
📤 Terminal Output / Interpretation:
1: lo: <LOOPBACK,UP> inet 127.0.0.1/8 2: eth0: <BROADCAST,UP> inet 192.168.1.50/24 default via 192.168.1.1 dev eth0 Netid State Recv-Q Send-Q Local Address:Port tcp LISTEN 0 128 0.0.0.0:22

Module 2: DNS Resolution & SSH Remote Administration

Domain Name System resolution and securing SSH remote server access.

🇬🇧 English Definition

DNS maps domain names to IP addresses (A/AAAA records, CNAME aliases, PTR reverse lookups). SSH provides encrypted remote server administration using public/private key authentication.

🇮🇳 Hinglish Definition

DNS domain name ko IP address me resolve karta hai. SSH remote server ko securely manage karne ka standard method hai.

Core Concepts & Rules

  • DNS Records: A (name to IPv4), CNAME (alias to domain), PTR (reverse IP to hostname).
  • Public vs Private Key: Public key is copied to server (~/.ssh/authorized_keys); Private key remains secret on client.
  • SSH Hardening: Disable direct root login (PermitRootLogin no), disable password authentication, use non-standard ports.

🔍 Line-by-Line Command Breakdown

  1. Line 1: dig example.com queries DNS server for A record domain resolution.
  2. Line 2: ssh-keygen -t ed25519 generates modern high-security SSH key pair.
  3. Line 3: ssh-copy-id user@server copies public key to remote server authorized_keys file.

🎯 Interview Focus & Questions

  • Q: A vs CNAME record?
    A: A maps a domain name directly to an IPv4 address; CNAME aliases one hostname to another domain name.
  • Q: Public vs private key?
    A: The public key is placed on the server; the private key stays on the client and must be kept secure.
💻 Command Example & Terminal Output - DNS Resolution & SSH Remote Administration
dig example.com
dig A example.com
dig -x 8.8.8.8
ssh-keygen -t ed25519
ssh-copy-id user@server
ssh -i ~/.ssh/id_ed25519 user@server
📤 Terminal Output / Interpretation:
;; ANSWER SECTION: example.com. 86400 IN A 93.184.216.34 /usr/bin/ssh-copy-id: INFO: 1 key(s) added Number of key(s) added: 1

Module 3: Firewall Control & SELinux Security Policies

Filtering network traffic using UFW/firewalld and enforcing mandatory access control with SELinux.

🇬🇧 English Definition

A firewall controls network packet traffic based on security rules. SELinux (Security-Enhanced Linux) is a Mandatory Access Control (MAC) system using security labels and policy rules.

🇮🇳 Hinglish Definition

Firewall network traffic ko allow/deny karta hai. SELinux standard permissions ke aage mandatory policy controls enforce karta hai.

Core Concepts & Rules

  • SELinux Modes: Enforcing (blocks & logs violations), Permissive (logs violations without blocking), Disabled.
  • restorecon: Restores default file security contexts based on SELinux policy database.

🔍 Line-by-Line Command Breakdown

  1. Line 1: sudo ufw allow 22/tcp opens SSH port 22 in UFW firewall.
  2. Line 2: getenforce checks current SELinux execution mode (Enforcing/Permissive).
  3. Line 3: ls -Z displays SELinux security context labels assigned to files.

🎯 Interview Focus & Questions

  • Q: Host Firewall vs Cloud Security Group?
    A: A host firewall operates inside the OS; a cloud security group is virtual network infrastructure control outside the OS.
  • Q: Why can an application fail with correct Unix permissions?
    A: SELinux security policy or label mismatch may still deny access; inspect SELinux contexts and audit logs.
💻 Command Example & Terminal Output - Firewall Control & SELinux Security Policies
sudo ufw status
sudo ufw allow 22/tcp
sudo firewall-cmd --state
sudo firewall-cmd --list-all
getenforce
sestatus
ls -Z /var/www
sudo restorecon -Rv /var/www
📤 Terminal Output / Interpretation:
Status: active To Action From -- ------ ---- 22/tcp ALLOW Anywhere Enforcing SELinux status: enabled SELinux mount point: /sys/fs/selinux drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www