Interview Prep/Linux/Networking, SSH and remote access

A web server should accept HTTP/HTTPS from anywhere but SSH only from the office. Configure the firewall.

BeginnerScenarioNetworking, SSH and remote access
Answer

Situation read → Host firewall with an allowlist for SSH.

What I'd do → firewalld:

sudo firewall-cmd --permanent --add-service={http,https}
sudo firewall-cmd --permanent --remove-service=ssh
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.0/24" service name="ssh" accept'
sudo firewall-cmd --reload && sudo firewall-cmd --list-all

ufw: ufw allow 80,443/tcp && ufw allow from 203.0.113.0/24 to any port 22 proto tcp && ufw enable.

Why → Narrow SSH exposure removes most brute-force noise.

Interview tip → In the cloud, do the same in the security group and keep the host firewall as a second layer.

All Linux questions Roadmap: Linux

More on Networking, SSH and remote access