Course contentsShow
← Cloud and Infrastructure
Lesson 60 of 2,9892. Compute FoundationsFree lesson

Security Groups and VM Firewalls

Understand instance-level firewall rules that control inbound and outbound network traffic to VMs.

Security Groups and VM Firewalls

What you'll learn: How to control which network traffic can reach your virtual machines using instance-level firewall rules.

What Are Security Groups?

Security groups act as virtual firewalls that sit directly in front of your VMs. They determine which inbound (incoming) and outbound (outgoing) network traffic is allowed to reach or leave your instances.

Think of a security group like a bouncer at a nightclub entrance. The bouncer checks a list of rules: "Only people from these addresses can enter" or "You can only leave through this specific exit." Similarly, security groups check every network packet against their rules before allowing it through.

How Security Groups Work

Security groups operate using allow rules only—you specify what traffic is permitted, and everything else is automatically blocked. Each rule typically defines:

  • Direction: Inbound or outbound
  • Protocol: TCP, UDP, ICMP, etc.
  • Port range: Which ports to open (e.g., port 22 for SSH, port 3389 for RDP)
  • Source/Destination: IP addresses or ranges allowed to connect

For example, to allow SSH access to a Linux VM, you'd create an inbound rule permitting TCP traffic on port 22 from your office IP address. This combines with the SSH key pairs you learned earlier to secure remote access.

Instance-Level Protection

Unlike traditional network firewalls that protect entire subnets, security groups attach directly to individual VMs. This provides defense in depth—even if VMs share the same network, each can have different firewall rules based on its specific role and security requirements.

Key Takeaway: Security groups are virtual firewalls that use allow-list rules to control inbound and outbound traffic at the VM level, providing granular security for each instance in your cloud environment.