Public IP address service
The public (external) IP address network service allows you to connect from the internet to a workload virtual machine (VM), a management appliance, or a load balancer running in your private cloud. For example, if you run a web server on your workload VM, you can serve web traffic using a public IP address through the internet. By default, the public IP network service is disabled.
Allocating a public IP address to a resource also provides the following benefits:
- Distributed denial of service (DDoS) attack prevention. This protection is automatically enabled for the public IP address.
- Always-on traffic monitoring and real-time mitigation of common network-level attacks.
- Protection and mitigation of attacks across the entire scale of the global network. The network can be used to distribute and mitigate attack traffic across regions.
Behavior
A public IP address can only be assigned to one private IP address, and the public IP address is dedicated to that private IP address until you unassign it. A resource associated with a public IP address always uses the public IP address for internet access. You can reserve up to 100 public IP addresses for the primary VPC network connected to VMware Engine.
By default, incoming traffic on a public IP address is denied, and only outbound internet access is allowed. To allow inbound traffic, create a firewall rule for the public IP address to the specific port.
gcloud and API prerequisites
To use the gcloud
command line tool or the API to manage your VMware Engine
resources, we recommend configuring the tools as described below.
gcloud
Set your default project ID:
gcloud config set project PROJECT_ID
Set a default region and/or zone:
gcloud config set compute/region REGION
gcloud config set compute/zone ZONE
For more information on the gcloud vmware
tool,
reviewing the Cloud SDK reference docs.
API
API examples in this documentation set use the cURL
command-line tool to
query the API. A valid access token is required as part of the cURL
request.
There are many ways to get a valid access token; the following steps use the
gcloud
tool to generate a access token:
Login to Google Cloud
gcloud auth login
Generate access token and export to TOKEN
export TOKEN=`gcloud auth print-access-token`
Verify that TOKEN is set properly
echo $TOKEN Output: TOKEN
Now, use the authorization token in your requests to the API. For example:
curl -X GET -H "Authorization: Bearer \"$TOKEN\"" -H "Content-Type: application/json; charset=utf-8" https://vmwareengine.googleapis.com/v1/projects/PROJECT_ID/locations
Python
Python code samples in this documentation use the VMware Engine library to communicate with the API. To be able to use this approach, the library needs to be installed and the Application Default Credentials should be configured.
Download and install the Python library
pip install google-cloud-vmwareengine
Configure the ADC information by executing those command in your shell
gcloud auth application-default login
or use a Service Account key file
export GOOGLE_APPLICATION_CREDENTIALS="FILE_PATH"
For more information about the library, visit the reference page or view code samples on GitHub.
Enabling the public IP network service in a region
Before you can allocate a public IP address to a workload VM, you must enable the public IP network service in the region:
Console
- Access the VMware Engine portal.
- Go to Network > Regional settings.
- In the row corresponding to the region of interest, select Edit. If the region is not listed in the summary table, add the region by clicking Add region.
- Toggle Public IP Service to Enabled.
- To enable the public IP service, you must also enable the internet access network service.
- It's possible to enable the internet access service and leave the public IP service disabled. If you do so, point-to-site VPN and public IP allocation are not available.
- In the Edge Services CIDR field, enter the address range to use when addressing the VMware Engine public IP gateway (/26 address range).
- Click Submit.
The status for the network service changes to Enabled when the operation is complete, usually after several minutes.
gcloud
Using the gcloud
tool, run the following command to create network policy:
gcloud vmware network-policies create NETWORK_POLICY_NAME \ --vmware-engine-network NETWORK_NAME --edge-services-cidr IP_RANGE \ --location REGION --external-ip-access --internet-access
Replace the following:
NETWORK_POLICY_NAME
: the name for this network policyNETWORK_NAME
: the network for this request, this must be in the formatREGION-default
IP_RANGE
: the CIDR range to use for internet access and external IP access gateways, in CIDR notation. An RFC 1918 CIDR block with a "/26" prefix is requiredREGION
: the region of the network
API
curl -X POST -H "Authorization: Bearer TOKEN" -H "Content-Type: application/json; charset=utf-8" https://vmwareengine.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/networkPolicies?networkPolicyId=NETWORK_POLICY_NAME -d '{ "vmwareEngineNetwork":"projects/PROJECT_ID/locations/REGION/vmwareEngineNetworks/NETWORK_NAME", "edgeServiceCidr":IP_RANGE, "internetAccess: { "enabled": true }, "externalIp": { "enabled": true } }
Replace the following:
NETWORK_POLICY_NAME
: the name for this network policy.PROJECT_ID
: the project ID for this requestREGION
: the region of the networkIP_RANGE
: the CIDR range to use for internet access and external IP access gateways, in CIDR notation. An RFC 1918 CIDR block with a "/26" prefix is required.NETWORK_NAME
: the network this network policy applies to, must be in the format>REGION-default
Python
Create a new network policy with external_ip and internet_access set to True
with the following function:
Allocating a public IP address
To allocate a public IP address for a workload VM, do the following:
- Access the Google Cloud VMware Engine portal
- Go to Network > Public IPs.
- Click Allocate.
- In the Name field, enter a name to identify the public IP address entry.
- Select the Private cloud that contains the workload VM.
- Select the Location where you want to serve the allocated public IP.
- In the Attached local address field, enter the local IP address of the VM that you want to assign this public IP address to.
- Click Submit to begin the task of allocating the public IP address.
You can check the status of the task on the Activity > Tasks page. When allocation is complete, the new entry appears on the Public IPs page with the Operational status.