Bitzu

Associate Cloud Engineer ยท VPC design and firewalls

VPC firewall rules: the building blocks

Implied rules, priority, direction, action, targets (all instances, network tags, service accounts), sources/destinations, protocols and ports, creating rules with gcloud.

Key points

  • A rule has a direction (ingress or egress), an action (allow or deny), a priority (0-65535, default 1000, lower wins), targets (all instances, network tags or service accounts), a source or destination, and protocols/ports.
  • Rules are stateful: return traffic of an allowed connection is allowed.
  • With nothing matching, the implied rules deny ingress and allow egress.

Source: https://docs.cloud.google.com/vpc/docs/firewalls

Practice questions

Single choice

In a network with no custom rules, what do the implied rules do?

  1. Deny ingress and allow egress
  2. Allow ingress and deny egress
  3. Allow both directions
  4. Deny both directions
Show answer

Answer: A. Deny ingress and allow egress

The implied behavior denies incoming and allows outgoing traffic. The reverse or symmetric options misstate this.

Select all that apply

Which can be used as the target of a VPC firewall rule?

  1. All instances in the network
  2. Instances with a network tag
  3. Instances running as a given service account
  4. Instances of a given machine type
  5. Instances with a given label
Show answer

Answer: A. All instances in the network, B. Instances with a network tag, C. Instances running as a given service account

A rule can target all instances, network tags or service accounts. Machine type and labels are not target selectors.

True or false

A deny rule always beats an allow rule, regardless of their priorities.

Show answer

Answer: False

False. Priority decides first; deny wins over allow only when both have the same priority.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Associate Cloud Engineer topics in this module