Description
Compute Engine instance cannot forward a packet unless the source IP address of the packet matches the IP address of the instance. Similarly, GCP won't deliver a packet whose destination IP address is different than the IP address of the instance receiving the packet. However, both capabilities are required if you want to use instances to help route packets.
Forwarding of data packets should be disabled to prevent data loss or information disclosure.
Rationaleโ
Compute Engine instance cannot forward a packet unless the source IP address of the packet matches the IP address of the instance. Similarly, GCP won't deliver a packet whose destination IP address is different than the IP address of the instance receiving the packet. However, both capabilities are required if you want to use instances to help route packets. To enable this source and destination IP check, disable the canIpForward field, which allows an instance to send and receive packets with non-matching destination or source IPs.
Impactโ
Deleting instance(s) acting as routers/packet forwarders may break the network connectivity.
Auditโ
From Google Cloud Consoleโ
- Go to the
VM Instancespage by visiting: https://console.cloud.google.com/compute/instances. - For every instance, click on its name to go to the
VM instance detailspage. - Under the
Network interfacessection, ensure thatIP forwardingis set toOfffor every network interface.
From Google Cloud CLIโ
-
List all instances:
gcloud compute instances list --format='table(name,canIpForward)' -
Ensure that
CAN_IP_FORWARDcolumn in the output of above command does not containTruefor any VM instance.
Exceptionโ
Instances created by GKE should be excluded because they need to have IP forwarding enabled and cannot be changed. Instances created by GKE have names that start with gke-.
Default Valueโ
By default, instances are not configured to allow IP forwarding.
Referencesโ
Additional Informationโ
You can only set the canIpForward field at instance creation time. After an instance is created, the field becomes read-only.