I was preparing for a NSX-v engagement recently where the customer was so curious about the redundancy of all integrated components with the NSX environment. They insisted to add all their 3 local DNS servers to the NSX manager.
Normally, I configure two DNS servers which seems to be valid for the majority of use-cases I have seen. This configuration is easy enough to be made from the Admin GUI portal of the NSX manager.
You can simply logon to your NSX manager via https://<NSX_MGR_IP Address or FQDN>, then navigate to Manage Appliance Settings > Network > DNS Servers, and enter the primary & secondary DNS servers as shown in the below screenshots.
As you can notice, you can’t add more than 2 DNS servers using the GUI. So, how can we add 3 DNS servers to the NSX manager ? REST API comes into rescue in such case !
To begin, let’s download the NSX 6.4 API guide. NSX manager’s network configuration management is documented at pages 141,142. https://docs.vmware.com/en/VMware-NSX-Data-Center-for-vSphere/6.4/nsx_64_api.pdf
Let’s start by getting the current network configuration of our NSX manager. Issue the below call through a REST API client such as postman. API Call: Get /api/1.0/appliance-management/system/network
You can notice that we have 2 DNS servers configured. To add a third DNS servers to the list, we can do so through the below API call:
Header: Key = Content-Type, Value: Application/XML
Request: PUT /api/1.0/appliance-management/system/network
Body: <network> <hostName>nsxmgr-01a</hostname> <networkIPv4AddressDto> <ipv4Address>192.168.110.42</ipv4Address> <ipv4NetMask>255.255.255.0</ipv4NetMask> <ipv4Gateway>192.168.110.1</ipv4Gateway> </ networkIPv4AddressDto> <dns> <ipv4Address>192.168.110.10</ipv4Address> <ipv4Address>192.168.110.11</ipv4Address> <ipv4Address>192.168.110.12</ipv4Address> <domainList>corp.local</domainList> </dns> <isDynamicIPAddress>false</isDynamicIPAddress> </network>
You should get an output of Status: 200 OK if the API call execution went successfully.
The third DNS server entry should be added now to the NSX manager configuration. As this will not appear in the GUI interface, let’s validate that by a GET API call. API Call: GET /api/1.0/appliance-management/system/network
We can also validate this via the NSX manager CLI by issuing the command Show startup-Config from the enable mode.
Hope this post is informative,
Thanks for reading,