0
0
GCPcloud~10 mins

Firewall rule components (target, source, protocol) in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Firewall rule components (target, source, protocol)
Start: Define Firewall Rule
Set Target: Which VMs to protect
Set Source: Where traffic comes from
Set Protocol: What traffic type
Apply Rule: Allow or Deny traffic
Traffic checked against rule
Allow or Block traffic based on rule
This flow shows how a firewall rule is created by choosing targets, sources, and protocols, then applied to control traffic.
Execution Sample
GCP
firewall_rule = {
  'target': 'vm-instance-1',
  'source': '0.0.0.0/0',
  'protocol': 'tcp'
}
Defines a firewall rule targeting one VM, allowing TCP traffic from anywhere.
Process Table
StepComponentValue SetEffect on TrafficNotes
1Targetvm-instance-1Rule applies only to this VMLimits scope to one VM
2Source0.0.0.0/0Traffic from any IP allowedOpen to all sources
3ProtocoltcpOnly TCP traffic affectedOther protocols ignored
4Apply RuleAllowTCP traffic from any IP to vm-instance-1 allowedRule active
5Traffic CheckIncoming TCP from 192.168.1.5AllowedMatches source and protocol
6Traffic CheckIncoming UDP from 192.168.1.5BlockedProtocol mismatch
7Traffic CheckIncoming TCP from 10.0.0.1AllowedSource matches 0.0.0.0/0
8Traffic CheckIncoming TCP to vm-instance-2BlockedTarget mismatch
9End--No more traffic to check
💡 All traffic checked against rule; only TCP to vm-instance-1 from any source allowed
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
targetundefinedvm-instance-1vm-instance-1vm-instance-1vm-instance-1
sourceundefinedundefined0.0.0.0/00.0.0.0/00.0.0.0/0
protocolundefinedundefinedundefinedtcptcp
rule_appliedfalsefalsefalsefalsetrue
Key Moments - 3 Insights
Why does traffic to vm-instance-2 get blocked even if protocol and source match?
Because the target is set to vm-instance-1 only, traffic to vm-instance-2 does not match the target and is blocked (see execution_table row 8).
Why is UDP traffic blocked even if source and target match?
The protocol is set to TCP, so UDP traffic does not match the protocol condition and is blocked (see execution_table row 6).
What does source '0.0.0.0/0' mean in the rule?
It means traffic from any IP address is allowed, so source is not restricting traffic (see execution_table row 2).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 5, what happens to incoming TCP traffic from 192.168.1.5?
AIt is allowed
BIt is blocked due to source mismatch
CIt is blocked due to protocol mismatch
DIt is blocked due to target mismatch
💡 Hint
Check execution_table row 5 for traffic check results
At which step does the protocol get set to TCP?
AStep 1
BStep 3
CStep 2
DStep 4
💡 Hint
Look at execution_table row 3 where protocol is set
If the target was changed to 'vm-instance-2', what would happen to TCP traffic to vm-instance-1?
AIt would be blocked due to source mismatch
BIt would be allowed
CIt would be blocked due to target mismatch
DIt would be blocked due to protocol mismatch
💡 Hint
Refer to execution_table row 8 where target mismatch blocks traffic
Concept Snapshot
Firewall rules control traffic by specifying:
- Target: which VM(s) the rule applies to
- Source: where traffic comes from (IP ranges)
- Protocol: type of traffic (tcp, udp, icmp)
Traffic matching all components is allowed or denied.
Rules are applied in order to control network access.
Full Transcript
A firewall rule in GCP is made by choosing a target VM or group, a source IP range, and a protocol like TCP. The rule then allows or blocks traffic that matches these settings. For example, if the target is vm-instance-1, source is 0.0.0.0/0 (any IP), and protocol is TCP, then only TCP traffic from any IP to vm-instance-1 is allowed. Traffic to other VMs or other protocols is blocked. This step-by-step flow helps understand how each component affects traffic filtering.