IntroductionNameSurfer provides two alternative ways of making changes to DNS data: a forms-based WWW user interface for easy interactive use, and a command line interface (CLI) which is intended primarily for non-interactive use, such as automated updates and integration with existing applications. This document describes the use of the command line interface in detail.
The nsctl programThe NameSurfer command line interface consists of a program called nsctl, usually located in /usr/local/namesurfer/bin/nsctl.The nsctl program works by contacting the NameSurfer daemon on the local host using a TCP connection, and issuing update requests over that connection. Update requests are cryptographically authenticated, based on a shared secret stored in the file /usr/local/namesurfer/db/secrets. This file is owned by the user namesurf and is not readable by other users (except of course root). Therefore, only the users namesurf and root can make changes to the DNS data using nsctl. The command line interface has no concept of "user accounts" like the WWW user interface does.
Available nsctl commandsThe following commands are available :
Updating reverse mappings automaticallyThe nsctl program does not update reverse mappings by default. If you want automatic reverse updates similar to the ones performed by the WWW user interface, add the global option, --auto-reverse immediately following the nsctl command. This feature can be used with any command that causes changes to DNS data, such as update, xfer, or mf-load. For example,
nsctl --auto-reverse update --zone demo.net. --add pear A 10.0.0.3 nsctl --auto-reverse xfer --zone demo.net --ns 10.0.1.2 Managing zone dataCreating a new zone from scratchA new zone can be created from scratch using the nsctl addzone command. Initial zone data is given using --add arguments just as with the nsctl update command. You must give an SOA record in this way; giving other initial data is optional. In the following example, a SOA record and two NS records are given as initial data for the new zone.
nsctl zone-add --zone demo.net. \ --add @ SOA ns1 hostmaster 96041720 10800 3600 1814400 86400 \ --add @ NS ns1 \ --add @ NS ns2 Loading an entire zone by zone transferAn entire zone can be loaded into NameSurfer from another name server by using the nsctl xfer command. This command fetches the zone data by doing a zone transfer from a given name server, and creates an identical zone in NameSurfer. For example:
nsctl xfer --zone demo.net --ns 10.0.1.2The nsctl xfer command accepts the following options:
Loading an entire zone from a master fileAn entire zone can be loaded into NameSurfer from a RFC1035 master file by using the nsctl mf-load command. For example:
nsctl mf-load --zone demo.net --file /etc/namedb/demo.net.dbThe nsctl mf-load command accepts the following options:
Deleting an entire zoneAn entire zone can be deleted from NameSurfer by using the nsctl zone-del command. For example:
nsctl zone-del --zone demo.net.The nsctl zone-del accepts the following options :
Listing all managed zonesAll zones (and their corresponding views) managed by NameSurfer can be listed using nsctl zone-list. For example:nsctl zone-listThe following options can be used to limit what nsctl zone-list outputs:
Listing zone attributesList all attributes of a zone by using nsctl zone-get. For example:nsctl zone-get --zone example.comThe nsctl zone-get accepts the following option :
Modifying zone attributesAdding, deleting and updating zone attributes is done with nsctl zone-update command. For example :nsctl zone-update --zone example.com --add-param DEFAULT_TTL 86400 nsctl zone-update --zone example.com --del-param DEFAULT_TTL nsctl zone-update --zone example.com --upd-param DEFAULT_TTL 43200The nsctl zone-update accepts the following options :
Adding and deleting resource recordsThe most common use of the CLI is to incrementally update the DNS data for one or several names by adding and/or deleting some resource records.This is accomplished by the nsctl update command. Here are some examples of nsctl update commands:
nsctl update --zone demo.net. --add banana A 10.0.0.1 nsctl update --zone demo.net. --delete apple A 10.0.0.2 nsctl update --zone demo.net. \ --add orange MX 10 mailhub \ --add orange MX 20 mail.isp.net.The nsctl update command is followed by options beginning with a double dash (--):
<domain-name> [<TTL>] [<class>] <type> <RDATA> <domain-name> [<class>] [<TTL>] <type> <RDATA>Domain names with no trailing period are interpreted relative to the zone root given with the --zone option. Note that this way of interpreting a domain name that has no periods is similar to that of BIND, but different from that of the WWW user interface. If the TTL is omitted, the SOA MINIMUM value is used.
Manipulating user accountsListing user accountsListing all user accounts in the system with command nsctl user-list. For example:nsctl user-listThe command has no options. Adding a user accountAdding new users to NameSurfer is done with nsctl user-add. Here is an example of how to create user account called einar, with the password SalaSana :nsctl user-add --user einar --password aB4nZtU5fBQB6The nsctl user-add accepts the following options :
The encrypted passwords may be produced using existing software, such as the htpasswd program used with many WWW servers. If you don't have an existing in-house procedure for password encryption, the following short Perl script may be useful. It will read plaintext passwords from standard input, encrypt them, and print the encrypted passwords on standard output.
#!/usr/local/bin/perl5 sub salt { substr("./" . join("", "0".."9","A".."Z","a".."z"), int rand 64) } srand time; while (<>) { chomp; print crypt($_, salt.salt), "\n"; } Updating a user accountsnsctl user-update Enabling previously created user account :nsctl user-update --user einar --add-param U_STATUS enabled
Listing user attributesnsctl user-getnsctl user-get --user einar
Deleting a user accountnsctl user-delnsctl user-del --user einar
Manipulating groupsListing all groupsListing all groups in NameSurfer is done with command nsctl group-list. For example :nsctl group-listThe command has no options. Adding a new groupAdding a new group to NameSurfer is done with nsctl group-add command.For example, creating a group named example and adding demouser to newly created group : nsctl group-add --group example --description "Example group" nsctl group-update --group example --add-param G_STATUS enabled --assign demouser
Deleting a groupnsctl group-del Deleting a group from NameSurfer is done with command nsctl group-del command. For example :nsctl group-del --group example
List group attributesListing all attributes for a group is done with command nsctl group-get. For example :nsctl group-get --group example
Updating a groupUpdating group parameters is done with command nsctl group-update. For example :nsctl group-update --group example --assign demouser --add-param G_STATUS enabledNote: to update a group parameter, you need to use both --del-param and --add-param.
Group attributesGroup attributes are displayed with group-get command and can be manipulated with group-update command. The most useful attributes are :
Manipulating viewsListing viewsListing all views configured into NameSurfer is done with the command view-list. For example :nsctl view-listThe command has no options. Manipulating remote secondary serversPrint configurationThis command prints the configuration of a configured remote secondary, either dhcp or bind. Filename is always dhcpd.conf or named.conf, server is same as configured in WebUI. For example:nsctl secondary-print --file named.conf --server ns2.demo.net > ns2.named.confPrints out named.conf of ns2.demo.net to ns2.named.conf.
If the server is not of a managed type, output of this command will be empty. Adding remote secondaryThis command reads the configuration file specified and installs it to the NameSurfer Remote Secondary configuration database for the server specified. The file name may contain the full or a relative path to the file. This path part of the file name does not go to the database. The file name should be either named.conf or dhcpd.conf. For example:nsctl secondary-add --file named.conf --type managed_named --server ns2.demo.net --set "ssh_remote_user=namesurf"This adds a new Remote Secondary Server to NameSurfer and a initial configuration for it. Configuration can be edited afterwards from WebUI.
Contents of the configuration file are only meaningful for the managed server types. To set the remote user name for SSH connections correctly, the ssh_remote_user attribute must be set like shown on the example line, otherwise the value will be automatically set to the username of the current local user, which is likely to be incorrect. Removing a remote secondaryRemoving a remote secondary server is done with command secondary-remove. For example :nsctl secondary-remove --file named.conf --server ns2.demo.netRemoves the remote secondary ns2.demo.net from the system.
Checking the remote secondary configurationChecking the configuration for a managed secondary server is done with command secondary-check. For example :nsctl secondary-check --file named.conf --server ns2.demo.netwill check the named.conf of ns2.demo.net if it exists in the local database.
The command returns an error code if checking of a non-managed server is attempted or if the configuration is faulty. In case of faulty configuration, output of the check command that was run is also printed to standard error output. If everything is OK, the output of the command will be empty and a zero result code will be returned. Uploading configuration to remote secondaryUploading the configuration to a remote secondary is done with the command secondary-upload. For example :nsctl secondary-upload --file named.conf --server ns2.demo.netWill upload the named.conf file from local database to the server ns2.demo.net
If the secondary server is not managed by NameSurfer or if the upload fails, an error code will be returned. Process control of the remote secondary serverSecondary server process control is done with commands secondary-start, secondary-stop and secondary-reload. Examples :start: nsctl secondary-start --file named.conf --server ns2.demo.net stop: nsctl secondary-stop --file named.conf --server ns2.demo.net reload: nsctl secondary-reload --file named.conf --server ns2.demo.net
|