Managing NSX Manager Network Settings via Rest API

In this post we will learn how can we configure some of the network settings like DNS/Syslog and NTP configurations in NSX manager via Rest API.

We can do all this from NSX manager GUI also but if you are thinking about automating NSX manager deployment, then these Rest API knowledge can be pretty handy for configuring the appliance post its deployment.

Lets get started.

Query Network Settings

Below API query will give you an overview of NSX Manager IP settings, Hostname, DNS settings and domain name

# curl -k -u “admin:adminpwd” -X GET https://nsxmgr.alex.local/api/1.0/appliance-management/system/network/ | xmllint –format –

Configure DNS Server

If you have not configured any DNS server settings on your NSX appliance, you can do so by firing below query.

You need to supply an xml file which have info about your domain name and IP of DNS servers. If you have only one DNS server in your environment, you can remove one of the <ipv4Address> tag from the xml file

# curl -k -u “admin:admin:adminpwd” -H “Content-Type:application/xml” -d @dns.xml -X PUT https://nsxmgr.alex.local/api/1.0/appliance-management/system/network/dns

Cross Verify whether or not NSX appliance have been updated with DNS settings or not

Delete DNS Servers

This query will wipe out the DNS settings from the NSX appliance.

# curl -k -u “admin:adminpwd” -X DELETE https://nsxmgr.alex.local/api/1.0/appliance-management/system/network/dns

Query NTP Settings

If you have already configured time settings on NSX appliance from UI then below GET call to NSX will provide you three things. IP address of the NTP server, Current Time and Date and Timezone

# curl -k -u “admin:adminpwd” -X GET https://nsxmgr.alex.local/api/1.0/appliance-management/system/timesettings | xmllint –format –

Configure NTP Settings

If you have not specified any time settings on your NSX manager yet, then you can use below API call alongwith an xml file which have the details about IP of NTP server, your country timezone and current date and time

# curl -k -u “admin:adminpwd” -H “Content-Type:application/xml” -d @ntp.xml -X PUT https://nsxmgr.alex.local/api/1.0/appliance-management/system/timesettings

Content of the supplied XML file (ntp.xml) in this example

Delete NTP Settings

This API call will wipe out NTP settings from the NSX manager appliance

# curl -k -u “admin:adminpwd” -X DELETE https://nsxmgr.alex.local/api/1.0/appliance-management/system/timesettings/ntp

Query Syslog Server

# curl -k -u “admin:adminpwd” -X GET https://nsxmgr.alex.local/api/1.0/appliance-management/system/syslogserver | xmllint –format –

If you have not configured any syslog related settings then above query will produce below message

Configure Syslog Server

To configure syslog server you need to pass three parameters in the xml file i.e syslog server IP, syslog port and protocol to be used  

# curl -k -u “admin:adminpwd” -H “Content-Type:application/xml” -d @syslog.xml -X PUT https://nsxmgr.alex.local/api/1.0/appliance-management/system/syslogserver

You can verify the syslog settings by logging into your appliance.

Delete syslog server

# curl -k -u “admin:adminpwd” -X DELETE https://nsxmgr.alex.local/api/1.0/appliance-management/system/syslogserver

I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing. Be sociable :)

Leave a Reply