# Configure domain peering

This page shows you how to configure [domain peering](https://docs.cloud.google.com/managed-microsoft-ad/docs/domain-peering.md.txt) with Managed Service for Microsoft Active Directory (Managed Microsoft AD).

## Before you begin

1. [Create a Managed Microsoft AD domain](https://docs.cloud.google.com/managed-microsoft-ad/docs/create-domain.md.txt) in the domain resource project.
2. [Create a VPC network](https://docs.cloud.google.com/vpc/docs/create-modify-vpc-networks.md.txt) in the VPC resource project to which you want to peer your domain with.
3. Make sure that the IP ranges assigned to Managed Microsoft AD and any authorized networks don't overlap.
4. Make sure that you have any one of the following IAM roles:
   - Google Cloud Managed Identities Admin (`roles/managedidentities.admin`)
   - Google Cloud Managed Identities Peering Admin (`roles/managedidentities.peeringAdmin`)
5. Optional: Check if you have the following IAM roles as well:
   - Google Cloud Managed Identities Viewer (`roles/managedidentities.viewer`)
   - Compute Network User (`roles/compute.networkUser`)
   - Compute Network Viewer (`roles/compute.networkViewer`)

> [!NOTE]
> **Note:** Be sure to enable the APIs and create the VPC in the same project where you enabled billing.

## Configure domain peering

After you complete the prerequisites and gather your domain information, you
can create the domain peering.

### Console

To create a peering from the domain resource project, follow these steps:

1. In the Google Cloud console, go to the **Managed Microsoft AD** page.  
   [Go to Managed Microsoft AD](https://console.cloud.google.com/security/cloud-ad)
2. Click the **Peerings** tab.
3. On the **Peerings** page, click **Create peering**.
4. In the **Name** field, enter a name for your peering resource.
5. Select **Domain**.
6. In the **Select domain from this project** list, select your Managed Microsoft AD domain.
7. Enter the project ID or number that includes the VPC network you want to peer with.
8. Enter the name of your VPC network.
9. Optional: To add labels, expand the **Labels** section. Click **Add labels**, and then enter the key-value pairs.
10. Click **Create**.

After the operation is complete, the **Peerings** page lists the peering with status as **Disconnected**.

To create a peering from the VPC resource project, follow these steps:

1. In the Google Cloud console, go to the **Managed Microsoft AD** page.  
   [Go to Managed Microsoft AD](https://console.cloud.google.com/security/cloud-ad)
2. Click the **Peerings** tab.
3. On the **Peerings** page, click **Create peering**.
4. In the **Name** field, enter a name for your peering resource.
5. Select **Network**.
6. In the **Select network from this project** list, select your VPC network.
7. Enter the project ID or number that includes your Managed Microsoft AD domain.
8. Enter the name of your Managed Microsoft AD domain.
9. Optional: To add labels, expand the **Labels** section. Click **Add labels**, and then enter the key-value pairs.
10. Click **Create**.

After the operation is complete, the **Peerings** page lists the peerings with status as **Connected** on both the projects.

### gcloud

Run the following gcloud CLI command.

```
gcloud active-directory peerings create PEERING_RESOURCE_NAME \
  --domain=DOMAIN_NAME \
  --authorized-network=VPC_NETWORK_NAME
```

Replace the following:

- `PEERING_RESOURCE_NAME`: a name for your domain peering resource (such as *my-domain-peering*).
- `DOMAIN_NAME`: a **[full resource name](https://docs.cloud.google.com/iam/docs/full-resource-names.md.txt)** for your Managed Microsoft AD domain, in the form of: `projects/PROJECT_ID/locations/global/domains/DOMAIN_NAME`.
- `VPC_NETWORK_NAME`: a **[full resource name](https://docs.cloud.google.com/iam/docs/full-resource-names.md.txt)** for your VPC network, in the form of: `projects/PROJECT_ID/global/networks/NETWORK_NAME`.

You receive the following response that indicates domain peering creation has
started:

```
Create request issued for: PEERING_RESOURCE_NAME
Waiting for operation-1842751234221-5857b78a1a49e-02bc63a3-77e5c7ee to complete...
```

After the operation is complete, configure domain peering in the VPC resource
project.
Run the following gcloud CLI command.

```
gcloud active-directory peerings create PEERING_RESOURCE_NAME \
  --domain=DOMAIN_NAME \
  --authorized-network=VPC_NETWORK_NAME \
  --project=VPC_RESOURCE_PROJECT_ID
```

Replace the following:

- `PEERING_RESOURCE_NAME`: a name for your domain peering resource (such as *my-domain-peering*).
- `DOMAIN_NAME`: a **[full resource name](https://docs.cloud.google.com/iam/docs/full-resource-names.md.txt)** for your Managed Microsoft AD domain, in the form of: `projects/PROJECT_ID/locations/global/domains/DOMAIN_NAME`.
- `VPC_NETWORK_NAME`: a **[full resource name](https://docs.cloud.google.com/iam/docs/full-resource-names.md.txt)** for your VPC network, in the form of: `projects/PROJECT_ID/global/networks/NETWORK_NAME`.
- `VPC_RESOURCE_PROJECT_ID`: the project ID of the VPC network project that is hosting the VPC.

You receive the following response that indicates domain peering creation has started:

```
Create request issued for: PEERING_RESOURCE_NAME
Waiting for operation-1842751821453-5857b78a1a49e-02bc63a3-77e5c7ee to complete...
```

This operation can take up to 15 mins to complete.
You can repeat the process to create multiple domain peerings in a project.
However, you can peer up to 10 VPC networks with a Managed Microsoft AD domain.

## What's next

- [Manage domain peerings](https://docs.cloud.google.com/managed-microsoft-ad/docs/list-describe-delete-domain-peering.md.txt)
- [Join a Windows VM to a domain](https://docs.cloud.google.com/managed-microsoft-ad/docs/quickstart-domain-join-windows.md.txt)
- [Join a Linux VM to a domain](https://docs.cloud.google.com/managed-microsoft-ad/docs/quickstart-domain-join-linux.md.txt)
- [Connect to a Managed Microsoft AD domain](https://docs.cloud.google.com/managed-microsoft-ad/docs/connect-to-active-directory-domain.md.txt)