Add DNS to External Network in VMware Cloud Director OpenAPI

Published by Jimmy Mankowitz on

Background

Content

When trying to add or Edit DNS servers to an External Network that is imported from a NSX-T Segment in Cloud Director the Edit is greyed out. This makes it not possible via UI to edit.

The reason we want DNS on the External network might be a Use-Case where we want to utilize Static IP Pool from External Network as a Direct Imported Network for a Tenant Organization VDC vAPP and also receive the DNS servers for the VMs in the vAPP.
We do not want to add a DHCP server on this network but wish to utilize the Static Pool funtionallity.

Cloud Director OpenAPI

So inorder to accomplish this we need to utilize Cloud Director OpenAPI.
If you type https://clouddirector.test.local/docs or go to https://developer.vmware.com/apis/1245/vmware-cloud-director you will get the examples for API calls. You can also search for External in this case. to get examples of how the API calls should look. and also how the Request body and headers should look like.

Get Authorization Token for Login

First we get the Authorization Token from vCD
We run a POST command against VCD api sessions in Postman Client

POST https://vclouddirector.test.local/api/sessions
Accept application/*;version=36.3
Content-Type application/json;version=36.3

Look in response Header for X-VMWARE-VCLOUD-ACCESS-TOKEN 
This is our response token:

YGn67XkfJdgUPn6fCfZt72FWRmpBcVH76xJjhFjugG1k1Ieh44KdlCNW5eoh6j-aMC3VCpUWcyoikOZstJUpEgKtxdQJQdmVyc2lvbiI6InZjbG91ZF8xLjAiLCJqdGkiOiJlZGE3ZGQ5MDVlYzE0MzQ4OGZlY2NiYmNiMjgzZjdkNiJ9.C01U5dfQsqq9QqEpP6m0zEenxvKvyJ2NbWHz8kjUxi1y3sRw3yRj0o0SUrCylJhq_3i3olgURH-Gt_MGPR5iKLP2ZCzYyhZTBHE87TxXFOm0vxbf1_DgRJ1wODRT9kQCbKDhEN1XtTjY5VpAzHFT8Scz7nD3u5EuTjgVSJxl92oYGn67XkfJdgUPn6fCfZt72FWRmpBcVH76xJjhFjugG1k1Ieh44KdlCNW5eoh6j-aMC3VCpUWcyoikOZstJhxEsbEUIaoHA1wwDGVUXMLDqjDa7A2NI7qnh4O2ZdnAuGX3LkSePE4hi1d0psXpbVzFmR6pVVL5nREUpEgKtxdQJQ

Change Authorization Type to Bearer Token and paste the Token

List all ExternalNetworks

We then run the API to get all ExternalNetworks

GET https://vclouddirector.test.local/cloudapi/1.0.0/externalNetworks

We search for our External Network and copy the id

We copy the id and add it to our next GET call after ExternalNetworks

GET https://vclouddirector.test.local/cloudapi/1.0.0/externalNetworks/urn:vcloud:network:9b89d4e3-7bb3-4c3a-bf2f-08b5379cc223

Update ExternalNetwork with DNS

We then copy the response and paste it into a new PUT body
Editing and adding our DNS server IPs.

PUT https://vclouddirector.test.local/cloudapi/1.0.0/externalNetworks/urn:vcloud:network:9b89d4e3-7bb3-4c3a-bf2f-08b5379cc223
We should get a 200 Response.

Verify in VCD UI vAPP DNS is working

We then jump back into Cloud Director UI and check the External Network for the update of the DNS. The DNS servers are visible for a Tenant in a vAPP that is connected to the External Network

Hope this can help you if you find yourself struggling with this issue.

Happy New Year!


0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *