Firewall Rules Logging  |  Cloud NGFW  |  Google Cloud (2024)

Sign in
  • Cloud NGFW

Contact Us Start free

  • Home
  • Cloud NGFW
  • Documentation
  • Guides
Stay organized with collections Save and categorize content based on your preferences.

Firewall Rules Logging lets you audit, verify, and analyze theeffects of your firewall rules. For example, you can determine if a firewallrule designed to deny traffic is functioning as intended.Firewall Rules Logging is also useful if you need to determine howmany connections are affected by a given firewall rule.

You enable Firewall Rules Logging individually for each firewall rulewhose connections you need to log. Firewall Rules Logging is an optionfor any firewall rule, regardless of the action (allow or deny) or direction(ingress or egress) of the rule.

Firewall Rules Logging logs traffic to and from Compute Enginevirtual machine (VM) instances. This includesGoogle Cloud products built on Compute EngineVMs, such as Google Kubernetes Engine (GKE)clusters andApp Engine flexible environment instances.

When you enable logging for a firewall rule, Google Cloud creates an entrycalled a connection record each time the rule allows or denies traffic. Youcan view these records in Cloud Logging, and you can export logsto any destination that Cloud Logging export supports.

Each connection record contains the source and destination IP addresses, theprotocol and ports, date and time, and a reference to the firewall rule thatapplied to the traffic.

Firewall Rules Logging is available for both VPCfirewall rules and hierarchical firewall policies.

For information about viewing logs, see UseFirewall Rules Logging.

Specifications

Firewall Rules Logging has the following specifications:

  • You can only enable Firewall Rules Logging for rules in aVirtual Private Cloud (VPC) network.Legacy networks are not supported.
  • Firewall Rules Logging only records TCP and UDP connections. Although you cancreate a firewall rule applicable to otherprotocols, you cannot log their connections.If you want to also log other protocols, consider usingPacket Mirroring.
  • You cannot enable Firewall Rules Logging for theimplied deny ingress and implied allow egress rules.
  • Log entries are written from the perspective of VMs. Log entriesare only created if a firewall rule has logging enabled and if the ruleapplies to traffic sent to or from the VM. Entries are created according tothe connection logging limits on a best effort basis.
  • The number of connections that can be logged in a giveninterval is based on the machine type.
  • Changes to firewall rules can be viewed inVPC audit logs.

Logging examples

A log entry is generated each time that a firewall rule with logging enabled appliesto traffic. A given packet flow can generate more than one log entry in total.However, from the perspective of a given VM, at most only one log entry can begenerated if the firewall rule that applies to it has logging enabled.

The following examples demonstrate how firewall logs work.

Egress deny example

In this example:

  • Traffic between VM instances in the example-net VPC network in theexample-proj project is considered.
  • The two VM instances are:
    • VM1 in zone us-west1-a with IP address 10.10.0.99 in thewest-subnet (us-west1 region).
    • VM2 in zone us-east1-b with IP address 10.20.0.99 in theeast-subnet (us-east1 region).
  • Rule A: An egress deny firewall rule has a target of all instances in thenetwork, a destination of 10.20.0.99 (VM2), and applies to TCP port 80.
    • Logging is enabled for this rule.
  • Rule B: An ingress allow firewall rule has a target of all instances in thenetwork, a source of 10.10.0.99 (VM1), and applies to TCP port 80.
    • Logging is also enabled for this rule.

The following gcloud commands can be used to create the firewall rules:

  • Rule A: egress deny rule for TCP 80, applicable to all instances,destination 10.20.0.99:

    gcloud compute firewall-rules create rule-a \ --network example-net \ --action deny \ --direction egress \ --rules tcp:80 \ --destination-ranges 10.20.0.99/32 \ --priority 10 \ --enable-logging
  • Rule B: ingress allow rule for TCP 80, applicable to all instances,source 10.10.0.99:

    gcloud compute firewall-rules create rule-b \ --network example-net \ --action allow \ --direction ingress \ --rules tcp:80 \ --source-ranges 10.10.0.99/32 \ --priority 10 \ --enable-logging

Suppose VM1 attempts to connect to VM2 on TCP port 80. The following firewallrules are logged:

  • A log entry for rule A from the perspective of VM1 is generated as VM1attempts to connect to 10.20.0.99 (VM2).
  • Because rule A actually blocks the traffic, rule B is never considered, sothere is no log entry for rule B from the perspective of VM2.

The firewall log record is generated in the following example.

FieldValues
connectionsrc_ip=10.10.0.99
src_port=[EPHEMERAL_PORT]
dest_ip=10.20.0.99
dest_port=80
protocol=6
dispositionDENIED
rule_detailsreference = "network:example-net/firewall:rule-a"
priority = 10
action = DENY
destination_range = 10.20.0.99/32
ip_port_info = tcp:80
direction = egress
instanceproject_id="example-proj"
instance_name=VM1
region=us-west1
zone=us-west1-a
vpcproject_id="example-proj"
vpc_name=example-net
subnetwork_name=west-subnet
remote_instanceproject_id="example-proj"
instance_name=VM2
region=us-east1
zone=us-east1-b
remote_vpcproject_id="example-proj"
vpc_name=example-net
subnetwork_name=east-subnet
remote_locationNo information. This field is only used if the destination is outside your VPC network.

Egress allow, ingress allow example

In this example:

  • Traffic between VM instances in the example-net VPC network in theexample-proj project is considered.
  • The two VM instances are:
    • VM1 in zone us-west1-a with IP address 10.10.0.99 in thewest-subnet (us-west1 region).
    • VM2 in zone us-east1-b with IP address 10.20.0.99 in theeast-subnet (us-east1 region).
  • Rule A: An egress allow firewall rule has a target of all instances in thenetwork, a destination of 10.20.0.99 (VM2), and applies to TCP port 80.
    • Logging is enabled for this rule.
  • Rule B: An ingress allow firewall rule has a target of all instances in thenetwork, a source of 10.10.0.99 (VM1), and applies to TCP port 80.
    • Logging is also enabled for this rule.

The following gcloud commands can be used to create the two firewall rules:

  • Rule A: egress allow rule for TCP 80, applicable to all instances,destination 10.20.0.99 (VM2):

    gcloud compute firewall-rules create rule-a \ --network example-net \ --action allow \ --direction egress \ --rules tcp:80 \ --destination-ranges 10.20.0.99/32 \ --priority 10 \ --enable-logging
  • Rule B: ingress allow rule for TCP 80, applicable to all instances,source 10.10.0.99 (VM1):

    gcloud compute firewall-rules create rule-b \ --network example-net \ --action allow \ --direction ingress \ --rules tcp:80 \ --source-ranges 10.10.0.99/32 \ --priority 10 \ --enable-logging

Suppose VM1 attempts to connect to VM2 on TCP port 80. The following firewallrules are logged:

  • A log entry for rule A from the perspective of VM1 is generated as VM1connects to 10.20.0.99 (VM2).
  • A log entry for rule B from the perspective of VM2 is generated as VM2 allowsincoming connections from 10.10.0.99 (VM1).

The firewall log record reported by VM1 is generated in the following example.

FieldValues
connectionsrc_ip=10.10.0.99
src_port=[EPHEMERAL_PORT]
dest_ip=10.20.0.99
dest_port=80
protocol=6
dispositionALLOWED
rule_detailsreference = "network:example-net/firewall:rule-a"
priority = 10
action = ALLOW
destination_range = 10.20.0.99/32
ip_port_info = tcp:80
direction = egress
instanceproject_id="example-proj"
instance_name=VM1
region=us-west1
zone=us-west1-a
vpcproject_id="example-proj"
vpc_name=example-net
subnetwork_name=west-subnet
remote_instanceproject_id="example-proj"
instance_name=VM2
region=us-east1
zone=us-east1-b
remote_vpcproject_id="example-proj"
vpc_name=example-net
subnetwork_name=east-subnet
remote_locationNo information. This field is only used if the destination is outside your VPC network.

The firewall log record reported by VM2 is generated in the following example.

FieldValues
connectionsrc_ip=10.10.0.99
src_port=[EPHEMERAL_PORT]
dest_ip=10.20.0.99
dest_port=80
protocol=6
dispositionALLOWED
rule_detailsreference = "network:example-net/firewall:rule-b"
priority = 10
action = ALLOW
source_range = 10.10.0.99/32
ip_port_info = tcp:80
direction = ingress
instanceproject_id="example-proj"
instance_name=VM2
region=us-east1
zone=us-east1-b
vpcproject_id="example-proj"
vpc_name=example-net
subnetwork_name=east-subnet
remote_instanceproject_id="example-proj"
instance_name=VM1
region=us-west1
zone=us-west1-a
remote_vpcproject_id="example-proj"
vpc_name=example-net
subnetwork_name=west-subnet
remote_locationNo information. This field is only used if the destination is outside your VPC network.

Internet ingress example

In this example:

  • Traffic from a system outside the example-net VPC network to a VMinstance in that network is considered. The network is in the example-projproject.
  • The system on the internet has IP address 203.0.113.114.
  • VM1 in zone us-west1-a has IP address 10.10.0.99 in the west-subnet(us-west1 region).
  • Rule C: An ingress allow firewall rule has a target of all instances in thenetwork, a source of any IP address (0.0.0.0/0), and applies to TCP port 80.
    • Logging is enabled for this rule.
  • Rule D: An egress deny firewall rule has a target of all instances in thenetwork, a destination of any IP address (0.0.0.0/0), and applies to allprotocols.
    • Logging is also enabled for this rule.

The following gcloud commands can be used to create the firewall rules:

  • Rule C: ingress allow rule for TCP 80, applicable to all instances,any source:

    gcloud compute firewall-rules create rule-c \ --network example-net \ --action allow \ --direction ingress \ --rules tcp:80 \ --source-ranges 0.0.0.0/0 \ --priority 10 \ --enable-logging
  • Rule D: egress deny rule for all protocols, applicable to all instances,any destination:

    gcloud compute firewall-rules create rule-d \ --network example-net \ --action deny \ --direction egress \ --rules all \ --destination-ranges 0.0.0.0/0 \ --priority 10 \ --enable-logging

Suppose the system with IP address 203.0.113.114 attempts to connect to VM1on TCP port 80. The following happens:

  • A log entry for rule C from the perspective of VM1 is generated as VM1 acceptstraffic from 203.0.113.114.
  • Despite rule D, VM1 is allowed to reply to the incoming request becauseGoogle Cloud firewall rules are stateful. If the incoming request isallowed, established responses cannot be blocked by any kind of egress rule.
  • Because rule D does not apply, it is never considered, sothere is no log entry for rule D.

The firewall log record is generated in the following example.

FieldValues
connectionsrc_ip=203.0.113.114
src_port=[EPHEMERAL_PORT]
dest_ip=10.10.0.99
dest_port=80
protocol=6
dispositionALLOWED
rule_detailsreference = "network:my-vpc/firewall:rule-c"
priority = 10
action = ALLOW
source_range = 0.0.0.0/0
ip_port_info = tcp:80
direction = ingress
instanceproject_id="example-proj"
instance_name=VM1
region=us-west1
zone=us-west1-a
vpcproject_id="example-proj"
vpc_name=example-net
subnetwork_name=west-subnet
remote_locationcontinent
country
region
city

Firewall log format

Subject to the specifications,a log entry is created in Cloud Logging for each firewall rule that haslogging enabled if that rule applies to traffic to or from a VM instance. Logrecords are included in the JSON payload field of a LoggingLogEntry.

Log records contain base fields, which are the core fields of every log record,and metadata fields that add additional information. You can control whethermetadata fields are included. If you omit them, you can save on storage costs.

Some log fields support values that are also fields. These fields can have morethan one piece of data in a given field. For example, the connection field isof the IpConnection format, which contains the source and destination IPaddress and port, plus the protocol, in a single field. These fields aredescribed in the following tables.

Field Description Field type: Base or optional metadata
connection IpConnection
5-Tuple describing the source and destination IP address, source and destination port, and IP protocol of this connection.
Base
disposition string
Indicates whether the connection was ALLOWED or DENIED.
Base
rule_details RuleDetails
Details of the rule that was applied to this connection.
rule_details.reference field Base
Other rule detail fields Metadata
instance InstanceDetails
VM instance details. In a Shared VPC configuration, project_id corresponds to that of the service project.
Metadata
vpc VpcDetails
VPC network details. In a Shared VPC configuration, project_id corresponds to that of the host project.
Metadata
remote_instance InstanceDetails
If the remote endpoint of the connection was a VM located in the Compute Engine, this field is populated with VM instance details.
Metadata
remote_vpc VpcDetails
If the remote endpoint of the connection was a VM that is located in a VPC network, this field is populated with the network details.
Metadata
remote_location GeographicDetails
If the remote endpoint of the connection was external to the VPC network, this field is populated with available location metadata.
Metadata

IpConnection

Field Type Description
src_ipstringSource IP address. If the source is a Compute Engine VM, src_ip is either the primary internal IP address or an address in an alias IP range of the VM's network interface. The external IP address is not shown. Logging shows the IP address of the VM as the VM sees it on the packet header, the same as if you ran TCP dump on the VM.
src_portintegerSource port
dest_ipstringDestination IP address. If the destination is a Google Cloud VM, dest_ip is either the primary internal IP address or an address in an alias IP range of the VM's network interface. The external IP address is not shown even if it was used in making the connection.
dest_portintegerDestination port
protocolintegerIP protocol of the connection

RuleDetails

FieldTypeDescription
referencestringReference to the firewall rule; format:
"network:{network name}/firewall:{firewall_name}"
priorityintegerThe priority for the firewall rule.
actionstringALLOW or DENY
source_range[]stringList of source ranges that the firewall rule applies to.
destination_range[]stringList of destination ranges that the firewall rule applies to.
ip_port_info[] IpPortDetailsList of IP protocols and applicable port ranges for rules.
directionstringThe direction that the firewall rule applies to (ingress or egress).
source_tag[]stringList of all the source tags that the firewall rule applies to.
target_tag[]stringList of all the target tags that the firewall rule applies to.
source_service_account[]stringList of all the source service accounts that the firewall rule applies to.
target_service_account[]stringList of all the target service accounts that the firewall rule applies to.
source_region_code[]stringList of all the source country codes that the firewall rule applies to.
destination_region_code[]stringList of all the destination country codes that the firewall rule applies to.
source_fqdn[]stringList of all the source domain names that the firewall rule applies to.
destination_fqdn[]stringList of all the destination domain names that the firewall rule applies to.
source_threat_intelligence[]stringList of all the source Threat Intelligence list names that the firewall rule applies to.
destination_threat_intelligence[]stringList of all the destination Threat Intelligence list names that the firewall rule applies to.
source_address_groups[]stringList of all the source address groups that the firewall rule applies to.
destination_address_groups[]stringList of all the destination address groups that the firewall rule applies to.

IpPortDetails

FieldTypeDescription
ip_protocolstringIP protocol that the firewall rule applies to. "ALL" if applies to all protocols.
port_range[]string List of applicable port ranges for rules; for example, 8080-9090.

InstanceDetails

FieldTypeDescription
project_idstringID of the project containing the VM
vm_namestringInstance name of the VM
regionstringRegion of the VM
zonestringZone of the VM

VpcDetails

FieldTypeDescription
project_idstringID of the project containing the network
vpc_namestringNetwork on which the VM is operating
subnetwork_namestringSubnet on which the VM is operating

GeographicDetails

FieldTypeDescription
continentstringContinent for external endpoints
countrystringCountry for external endpoints
regionstringRegion for external endpoints
citystringCity for external endpoints

What's next

  • To set up logging and view logs, see Use Firewall Rules Logging.
  • To get insights about how your firewall rules are being used,see Firewall Insights.
  • To store, search, analyze, monitor, and alert on log data and events, see Cloud Logging.
  • To route log entries, see Configure and manage sinks.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-09-10 UTC.

Firewall Rules Logging  |  Cloud NGFW  |  Google Cloud (2024)
Top Articles
Mortgage-Backed Securities (MBS) | Meaning, Kinds, Pros, Cons
Artificial Intelligence in Decision Making - Big Overview
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Lakeisha Bayer VM

Last Updated:

Views: 5558

Rating: 4.9 / 5 (49 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Lakeisha Bayer VM

Birthday: 1997-10-17

Address: Suite 835 34136 Adrian Mountains, Floydton, UT 81036

Phone: +3571527672278

Job: Manufacturing Agent

Hobby: Skimboarding, Photography, Roller skating, Knife making, Paintball, Embroidery, Gunsmithing

Introduction: My name is Lakeisha Bayer VM, I am a brainy, kind, enchanting, healthy, lovely, clean, witty person who loves writing and wants to share my knowledge and understanding with you.