0
0
GCPcloud~10 mins

Firewall rules concept in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the direction of the firewall rule.

GCP
resource "google_compute_firewall" "default" {
  name    = "allow-internal"
  network = "default"
  direction = "[1]"
}
Drag options to blanks, or click blank then click option'
AOUTBOUND
BEGRESS
CINBOUND
DINGRESS
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'INBOUND' or 'OUTBOUND' which are not valid values in GCP firewall rules.
2fill in blank
medium

Complete the code to allow TCP traffic on port 80.

GCP
resource "google_compute_firewall" "http" {
  name    = "allow-http"
  network = "default"
  allow {
    protocol = "[1]"
    ports    = ["80"]
  }
}
Drag options to blanks, or click blank then click option'
Ahttp
Budp
Ctcp
Dicmp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'http' as a protocol which is not valid in firewall rules.
3fill in blank
hard

Fix the error in the source range specification to allow traffic from any IP.

GCP
resource "google_compute_firewall" "allow-all" {
  name    = "allow-all"
  network = "default"
  allow {
    protocol = "tcp"
    ports    = ["0-65535"]
  }
  source_ranges = ["[1]"]
}
Drag options to blanks, or click blank then click option'
Aany
B0.0.0.0/0
C0.0.0.0
D255.255.255.255/32
Attempts:
3 left
💡 Hint
Common Mistakes
Using '0.0.0.0' without CIDR suffix which is invalid.
Using 'any' which is not accepted.
4fill in blank
hard

Fill both blanks to create a firewall rule that denies all egress UDP traffic.

GCP
resource "google_compute_firewall" "deny-udp-egress" {
  name    = "deny-udp-egress"
  network = "default"
  direction = "[1]"
  deny {
    protocol = "[2]"
  }
}
Drag options to blanks, or click blank then click option'
AEGRESS
BINGRESS
Cudp
Dtcp
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing INGRESS and EGRESS directions.
Using TCP instead of UDP.
5fill in blank
hard

Fill all three blanks to create a firewall rule allowing SSH from a specific IP range.

GCP
resource "google_compute_firewall" "allow-ssh" {
  name    = "allow-ssh"
  network = "default"
  direction = "[1]"
  allow {
    protocol = "[2]"
    ports    = ["[3]"]
  }
  source_ranges = ["192.168.1.0/24"]
}
Drag options to blanks, or click blank then click option'
AINGRESS
Btcp
C22
DEGRESS
Attempts:
3 left
💡 Hint
Common Mistakes
Setting direction to EGRESS instead of INGRESS.
Using wrong protocol or port.