NMCTL
NMCTL is a CLI tool for interacting with the Netmaker API.
Quick Start
Start with getting the latest nmctl binary specific to your operating system from the link below:
https://github.com/gravitl/netmaker/releases/latestMake sure the binary is executable with chmod +x nmctl and then move it into your /usr/sbin folder.
If everything is setup ok, you should be able to type nmctl and see the following:
CLI for interacting with Netmaker Server
Usage:
nmctl [command]
Available Commands:
acl Manage Access Control Lists (ACLs)
completion Generate the autocompletion script for the specified shell
context Manage various netmaker server configurations
dns Manage DNS entries associated with a network
enrollment_key Manage Enrollment Keys
ext_client Manage Remote Access Clients
help Help about any command
host Manage hosts
logs Retrieve server logs
metrics Fetch metrics of nodes/networks
network Manage Netmaker Networks
network_user Manage Network Users
node Manage nodes associated with a network
server Get netmaker server information
user Manage users and permissions
usergroup Manage User Groups
Flags:
-h, --help help for nmctl
Use "nmctl [command] --help" for more information about a command.Your CLI should be ready to go at this point.
Context
Before running any commands, a context has to be set which stores the API endpoint information. This allows the CLI to know which server to communicate with, and the user account to use.
NMCLI supports connecting to both standalone (self-hosted) and SaaS(managed) tenants. This is specified with a flag. More details below.
Connecting to standalone (self-hosted) tenants
Assuming your tenant is hosted at https://api.netmaker.example.com/
You can use your username and password that you use to sign in to the dashboard UI to set the context. Then you can set the CLI to use that context.
You can also authenticate via OAuth with the following:
Connecting to SaaS (managed) tenants
You can also authenticate with a managed (SaaS) tenant with the following commands:
You can also authenticate via OAuth with the following:
List and switch between contexts
You can see a list of all your contexts that you have created with the following:
That list also tells you what context/tenant is currently selected.
You can switch to a different context by using the use subcommand:
Delete contexts
You can delete a context with the following:
Network
Create a network with the name test_net and CIDR 10.11.13.0/24.
Fetch details of the created network.
Access Key
Create an access key for the created network with 100 uses. This key shall be used by nodes to join the network test_net.
Nodes
Connect a node to the network using https://docs.v2.netmaker.io/guide/getting-started/netclient and the access key created above. Use the accessstring as token.
List all nodes. This displays information about each node such as the address assigned, id, name etc
Using nmctl, we can turn the node into egress, remote access gateway or a relay. Lets turn the node into an remote access gateway by supplying the network name and node id as parameters.
Fetching the node list once again we can see that our node has been turned into a remote access gateway.
Remote Access Clients
Adding a Remote Access Client (https://docs.v2.netmaker.io/guide/features/remote-access-gateways-and-clients) to the network is just as easy. Requires the network name and node id as input parameters.
List all available Remote Access Clients.
The wireguard config of an Remote Access Client can also be fetched with the network name and client id.
ACLs
Access Control between hosts can be managed via the NMCTL CLI. These settings allow the network admin to specify which hosts are allowed to communicate between each other.
List
To list all access control settings for a network:
Allow / Deny
To allow communication between two hosts on a network:
To deny communication between two hosts:
Host IDs can be retrieved with the nmctl node list command.
The global –output flag can be used to format how a network’s ACLs are outputted.
Help
Further information about any subcommand is available using the --help flag
Example:
NMCTL - standalone
A brief guide to using netmaker from the command line (without the UI)
Normal Operations by user
(assume that users have been created by superadmin)
Was this helpful?