Interview Prep/Networking/Security: Firewalls, SGs, NACLs & VPN

How do you let only your office IP SSH into a server?

BeginnerScenarioSecurity: Firewalls, SGs, NACLs & VPN
Answer

Situation read → Least privilege on port 22.

What I'd do →

  1. Edit the security group inbound rule: aws ec2 authorize-security-group-ingress --group-id sg-0abc --protocol tcp --port 22 --cidr 203.0.113.7/32
  2. Remove any 0.0.0.0/0 rule for 22
  3. Better: use SSM Session Manager and close port 22
  4. Verify from outside with nc -vz server 22 and from another network, which should time out

Why → A /32 limits access to one address; a timeout from other sources shows the SG is dropping, not rejecting.

Interview tip → Mention that office IPs change, so a VPN with a fixed egress IP is more stable.

All Networking questions Roadmap: Networking for DevOps

More on Security: Firewalls, SGs, NACLs & VPN