The OpenThread CLI exposes configuration and management APIs from a command-line interface. Use OT CLI to create an OpenThread development environment, or use it as a tool with additional application code. For example, the OpenThread test scripts use the CLI to execute test cases.
Get started
Complete our Simulation Codelab with Docker and review the CLI Command Reference.
Go to the Simulation Codelab Go to the CLI Command Reference
Use OT CLI
You can use OT CLI with OpenThread Border Router (OTBR) and Thread devices. CLI commands will vary depending on your device type and build flags.
OTBR
To use OT CLI with OTBR, enter the following prefix before each command:
sudo ot-ctl
Thread devices
To use CLI Commands on a Thread device, refer to the platform documentation, codelab, or guide. For many examples, you can begin typing commands without a prefix:
state
router
Done
Here are a few resources to help you get started:
- Review OpenThread Platforms
- Nordic Hardware Codelab
- Silicon Labs Hardware Codelab
- Platform Examples on GitHub
Special characters
The whitespace character (' '
) is used to delimit the command name and the
different arguments, together with the tab ('\t'
) and new line characters
('\r'
, '\n'
).
Some arguments might include spaces, for example a Thread network name. To
send arguments that include spaces, use the backslash character ('\'
) to
escape separators or the backslash itself:
networkname Test\ Network
Donenetworkname
Test Network Done
Argument mappings
OT CLI uses predefined arguments that correspond to API configuration values. These mappings can be passed with CLI commands, and might also return to the CLI console for various Network Data commands, for example netdata show.
otBorderRouterConfig
Some commands, for example prefix add
, require
otBorderRouterConfig
values. To set otBorderRouterConfig
members from the command line, OT CLI
parses a mapped letter argument for each member. For example, the argument
combination paros
sets the
mPreferred,
mSlaac,
mDefaultRoute,
mOnMesh,
and mStable
members, consecutively.
Syntax
In the following example, prefix
is required, and
otBorderRouterConfig
arguments are optional, mapped as p
, a
, d
, c
, r
, o
, s
, n
, and
D
:
prefix add prefix [padcrosnD]
Usage
To use argument mappings, do not enter spaces between the letters:
prefix add 2001:dead:beef:cafe::/64 paros
otRoutePreference
To set the otRoutePreference,
use high
, med
, or low
in OT CLI commands.
Syntax
prefix add prefix [padcrosnD] [high|med|low]
Usage
Here's an example of using mapped otBorderRouterConfig
and otRoutePreference
parameters:
prefix add 2001:dead:beef:cafe::/64 paros med
Done
otExternalRouteConfig
For otExternalRouteConfig
values, s
maps to mStable
and n
maps to mNat64
.
Syntax
publish route prefix [sn]
Usage
route add 2001:dead:beef:cafe::/64 s
Done
Return values
Most commands return the requested value, followed by Done
:
br onlinkprefix
fd41:2650:a6f5:0::/64
Done
Other commands that include Network Data might return argument mappings for prefix, route, and service records. For more information, refer to Display and Manage Network Data with OT CLI.