unifi traffic
About 4700 words
Manage traffic rules, traffic routes and matching lists.
Manage the traffic side of the policy engine: rules that block, allow or throttle traffic by app, domain or region; routes that steer selected traffic through a specific WAN or VPN; and the port and address lists firewall policies match on.
Commands
unifi traffic lists: Manage port and IP address matching listsunifi traffic lists create: Create a traffic matching listunifi traffic lists delete: Delete one or more traffic matching listsunifi traffic lists describe: Show every field of one traffic matching listunifi traffic lists edit: Edit a traffic matching list in your editorunifi traffic lists get: List the traffic matching lists, or show oneunifi traffic lists set: Change fields of a traffic matching listunifi traffic routes: Manage traffic routesunifi traffic routes create: Create a traffic routeunifi traffic routes delete: Delete one or more traffic routesunifi traffic routes describe: Show every field of one traffic routeunifi traffic routes disable: Disable a traffic routeunifi traffic routes edit: Edit a traffic route in your editorunifi traffic routes enable: Enable a traffic routeunifi traffic routes get: List the traffic routes, or show oneunifi traffic routes set: Change fields of a traffic routeunifi traffic rules: Manage traffic rulesunifi traffic rules create: Create a traffic ruleunifi traffic rules delete: Delete one or more traffic rulesunifi traffic rules describe: Show every field of one traffic ruleunifi traffic rules disable: Disable a traffic ruleunifi traffic rules edit: Edit a traffic rule in your editorunifi traffic rules enable: Enable a traffic ruleunifi traffic rules get: List the traffic rules, or show oneunifi traffic rules set: Change fields of a traffic rule
unifi traffic lists
Manage port and IP address matching lists.
Aliases: list, matching-lists
Manage traffic matching lists: named lists of ports or IP addresses that firewall policies refer to, so a set of values is maintained in one place.
Items are objects such as {type: PORT_NUMBER, value: 443}; replace the whole list with --set 'items=[{type: PORT_NUMBER, value: 443}]', or write it with edit.
This kind is served by the official Network API.
unifi traffic lists create
Create a traffic matching list.
Usage
unifi traffic lists create <name> [flags]Create a traffic matching list from flags, from a file, or from both.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list. -f reads a manifest or a bare spec (-f - reads standard input); flags are applied on top of it. With a manifest that carries metadata.name, the name argument can be left out.
The quickest way to a valid spec is an existing object: unifi traffic lists get <name> --output yaml.
Examples
unifi traffic lists create "Web Ports" --type PORTS --set 'items=[{type: PORT_NUMBER, value: 443}]'
unifi traffic lists create "Web Ports" --filename matching-lists.yaml
unifi traffic lists create "Web Ports" -f - < spec.yamlFlags
| Flag | Description |
|---|---|
-f, --filename <file> | read the object from a manifest or spec file; - reads standard input |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
--type <string> | what the list holds: PORTS, IPV4_ADDRESSES, IPV6_ADDRESSES |
-y, --yes | do not ask for confirmation |
unifi traffic lists delete
Delete one or more traffic matching lists.
Usage
unifi traffic lists delete <name>... [flags]Aliases: rm
Delete one or more traffic matching lists after confirmation.
Every name is checked before anything is deleted, so a typo deletes nothing. Pass --yes to skip the confirmation, as scripts must. When several objects share a name, --id picks the one to delete.
Examples
unifi traffic lists delete "Web Ports"
unifi traffic lists delete "Web Ports" --yesFlags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic lists describe
Show every field of one traffic matching list.
Usage
unifi traffic lists describe <name> [flags]Show every field of one traffic matching list.
The kinds people look at most are laid out in words, with references shown by name; the others list their fields under the paths that unifi traffic lists set <name> --set <path>=<value> takes. --output yaml always prints the complete object as the controller spells it.
Secrets such as passphrases and keys read <redacted>. --show-secrets prints them in --output yaml and --output json, never in the text view. When several objects share the name, --id picks one.
Examples
unifi traffic lists describe "Web Ports"
unifi traffic lists describe "Web Ports" --output json
unifi traffic lists describe --id <id>Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
unifi traffic lists edit
Edit a traffic matching list in your editor.
Usage
unifi traffic lists edit <name> [flags]Open a traffic matching list as a YAML manifest in your editor and apply it on save.
The editor is taken from $VISUAL, then $EDITOR, then vi. What you save becomes the object's new state: removing a field removes it. Closing without changes, or emptying the file, cancels the edit.
Secrets such as passphrases and keys are shown as <redacted>. Leave that as it is to keep a secret, or type a new value over it to change it.
When the result is not a valid manifest or the controller rejects it, your edits are kept in a file whose path is printed, so nothing is lost.
Examples
unifi traffic lists edit "Web Ports"
unifi traffic lists edit "Web Ports" # with EDITOR="code --wait"Flags
| Flag | Description |
|---|---|
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic lists get
List the traffic matching lists, or show one.
Usage
unifi traffic lists get [name] [flags]Aliases: list, ls
List the traffic matching lists of the site, or show the one named by the argument.
--output wide adds columns and the object IDs. --output yaml and --output json print manifests that unifi apply -f - accepts unchanged.
--show-secrets keeps passphrases, keys and other secrets in --output yaml and --output json; without it they read <redacted>, which unifi apply understands as "keep the current value". Tables never show secrets.
--filter takes a filter expression such as enabled && name contains "guest". Fields are the object's own, as shown by --output yaml, plus name and id. --sort takes a column: name, type, items, or any field path.
Examples
unifi traffic lists get
unifi traffic lists get --output wide
unifi traffic lists get "Web Ports" --output yaml
unifi traffic lists get --filter 'type == "PORTS"'
unifi traffic lists get --output yaml > matching-lists.yamlFlags
| Flag | Description |
|---|---|
--filter <string> | filter expression, such as 'enabled && name contains "guest"' |
--id <id> | pick the object by its id, for objects that share a name |
--reverse | reverse the sort order |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
--sort <string> | sort by a column or field path: name, type, items |
unifi traffic lists set
Change fields of a traffic matching list.
Usage
unifi traffic lists set <name> [flags]Change fields of a traffic matching list and show what changed.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list (a list replaces the whole field). --unset path removes a field. --dry-run shows the change without making it.
Find the field paths with unifi traffic lists get <name> --output yaml.
Examples
unifi traffic lists set "Web Ports" --set 'items=[{type: PORT_NUMBER, value: 8443}]'
unifi traffic lists set "Web Ports" --set <path>=<value> --dry-run
unifi traffic lists set "Web Ports" --unset <path>Flags
| Flag | Description |
|---|---|
--dry-run | show what would change without changing it |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
--type <string> | what the list holds: PORTS, IPV4_ADDRESSES, IPV6_ADDRESSES |
--unset <path> | remove a field by its path, repeatable |
-y, --yes | do not ask for confirmation |
unifi traffic routes
Manage traffic routes.
Aliases: route
Manage traffic routes: send traffic of selected devices, matched by domain, IP address or region, through a specific WAN or VPN client tunnel.
A route is named by its description. Targets and matched domains are nested objects; write them with edit, or in a manifest for unifi apply.
This kind is served by the controller's internal v2 API, whose shape can change between UniFi Network versions.
unifi traffic routes create
Create a traffic route.
Usage
unifi traffic routes create <description> [flags]Create a traffic route from flags, from a file, or from both.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list. -f reads a manifest or a bare spec (-f - reads standard input); flags are applied on top of it. With a manifest that carries metadata.name, the name argument can be left out.
The quickest way to a valid spec is an existing object: unifi traffic routes get <description> --output yaml.
Examples
unifi traffic routes create "Streaming via Privacy VPN" --matching DOMAIN
unifi traffic routes create "Streaming via Privacy VPN" --filename traffic-routes.yaml
unifi traffic routes create "Streaming via Privacy VPN" -f - < spec.yamlFlags
| Flag | Description |
|---|---|
--enabled | whether the route is active; turn it off with --enabled=false |
-f, --filename <file> | read the object from a manifest or spec file; - reads standard input |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--kill-switch | whether traffic is dropped when the tunnel is down; turn it off with --kill-switch=false |
--matching <string> | what the route matches on, such as INTERNET, DOMAIN, IP, REGION |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
-y, --yes | do not ask for confirmation |
unifi traffic routes delete
Delete one or more traffic routes.
Usage
unifi traffic routes delete <description>... [flags]Aliases: rm
Delete one or more traffic routes after confirmation.
Every name is checked before anything is deleted, so a typo deletes nothing. Pass --yes to skip the confirmation, as scripts must. When several objects share a name, --id picks the one to delete.
Examples
unifi traffic routes delete "Streaming via Privacy VPN"
unifi traffic routes delete "Streaming via Privacy VPN" --yesFlags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic routes describe
Show every field of one traffic route.
Usage
unifi traffic routes describe <description> [flags]Show every field of one traffic route.
The kinds people look at most are laid out in words, with references shown by name; the others list their fields under the paths that unifi traffic routes set <description> --set <path>=<value> takes. --output yaml always prints the complete object as the controller spells it.
Secrets such as passphrases and keys read <redacted>. --show-secrets prints them in --output yaml and --output json, never in the text view. When several objects share the name, --id picks one.
Examples
unifi traffic routes describe "Streaming via Privacy VPN"
unifi traffic routes describe "Streaming via Privacy VPN" --output json
unifi traffic routes describe --id <id>Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
unifi traffic routes disable
Disable a traffic route.
Usage
unifi traffic routes disable <description> [flags]Disable a traffic route. It is a shortcut for unifi traffic routes set <description> --set enabled=false.
Examples
unifi traffic routes disable "Streaming via Privacy VPN"Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic routes edit
Edit a traffic route in your editor.
Usage
unifi traffic routes edit <description> [flags]Open a traffic route as a YAML manifest in your editor and apply it on save.
The editor is taken from $VISUAL, then $EDITOR, then vi. What you save becomes the object's new state: removing a field removes it. Closing without changes, or emptying the file, cancels the edit.
Secrets such as passphrases and keys are shown as <redacted>. Leave that as it is to keep a secret, or type a new value over it to change it.
When the result is not a valid manifest or the controller rejects it, your edits are kept in a file whose path is printed, so nothing is lost.
Examples
unifi traffic routes edit "Streaming via Privacy VPN"
unifi traffic routes edit "Streaming via Privacy VPN" # with EDITOR="code --wait"Flags
| Flag | Description |
|---|---|
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic routes enable
Enable a traffic route.
Usage
unifi traffic routes enable <description> [flags]Enable a traffic route. It is a shortcut for unifi traffic routes set <description> --set enabled=true.
Examples
unifi traffic routes enable "Streaming via Privacy VPN"Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic routes get
List the traffic routes, or show one.
Usage
unifi traffic routes get [description] [flags]Aliases: list, ls
List the traffic routes of the site, or show the one named by the argument.
--output wide adds columns and the object IDs. --output yaml and --output json print manifests that unifi apply -f - accepts unchanged.
--show-secrets keeps passphrases, keys and other secrets in --output yaml and --output json; without it they read <redacted>, which unifi apply understands as "keep the current value". Tables never show secrets.
--filter takes a filter expression such as enabled && name contains "guest". Fields are the object's own, as shown by --output yaml, plus name and id. --sort takes a column: name, matching, interface, enabled, or any field path.
Examples
unifi traffic routes get
unifi traffic routes get --output wide
unifi traffic routes get "Streaming via Privacy VPN" --output yaml
unifi traffic routes get --filter 'matching_target == "DOMAIN"'
unifi traffic routes get --output yaml > traffic-routes.yamlFlags
| Flag | Description |
|---|---|
--filter <string> | filter expression, such as 'enabled && name contains "guest"' |
--id <id> | pick the object by its id, for objects that share a name |
--reverse | reverse the sort order |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
--sort <string> | sort by a column or field path: name, matching, interface, enabled |
unifi traffic routes set
Change fields of a traffic route.
Usage
unifi traffic routes set <description> [flags]Change fields of a traffic route and show what changed.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list (a list replaces the whole field). --unset path removes a field. --dry-run shows the change without making it.
Find the field paths with unifi traffic routes get <description> --output yaml.
Examples
unifi traffic routes set "Streaming via Privacy VPN" --kill-switch=true
unifi traffic routes set "Streaming via Privacy VPN" --set <path>=<value> --dry-run
unifi traffic routes set "Streaming via Privacy VPN" --unset <path>Flags
| Flag | Description |
|---|---|
--dry-run | show what would change without changing it |
--enabled | whether the route is active; turn it off with --enabled=false |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
--kill-switch | whether traffic is dropped when the tunnel is down; turn it off with --kill-switch=false |
--matching <string> | what the route matches on, such as INTERNET, DOMAIN, IP, REGION |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
--unset <path> | clear a field by its path, repeatable: the controller's internal API keeps the key and stores an empty value |
-y, --yes | do not ask for confirmation |
unifi traffic rules
Manage traffic rules.
Aliases: rule
Manage traffic rules: block, allow or rate-limit traffic for selected devices or networks by app, app category, domain, IP address or region, optionally on a schedule.
A rule is named by its description. Targets and schedules are nested objects; write them with edit, or in a manifest for unifi apply.
This kind is served by the controller's internal v2 API, whose shape can change between UniFi Network versions.
unifi traffic rules create
Create a traffic rule.
Usage
unifi traffic rules create <description> [flags]Create a traffic rule from flags, from a file, or from both.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list. -f reads a manifest or a bare spec (-f - reads standard input); flags are applied on top of it. With a manifest that carries metadata.name, the name argument can be left out.
The quickest way to a valid spec is an existing object: unifi traffic rules get <description> --output yaml.
Examples
unifi traffic rules create "Kids bedtime" --action BLOCK --matching INTERNET
unifi traffic rules create "Kids bedtime" --filename traffic-rules.yaml
unifi traffic rules create "Kids bedtime" -f - < spec.yamlFlags
| Flag | Description |
|---|---|
--action <string> | what happens to matching traffic: BLOCK, ALLOW |
--enabled | whether the rule is active; turn it off with --enabled=false |
-f, --filename <file> | read the object from a manifest or spec file; - reads standard input |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--matching <string> | what the rule matches on, such as INTERNET, APP, APP_CATEGORY, DOMAIN, IP, REGION, LOCAL_NETWORK |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
-y, --yes | do not ask for confirmation |
unifi traffic rules delete
Delete one or more traffic rules.
Usage
unifi traffic rules delete <description>... [flags]Aliases: rm
Delete one or more traffic rules after confirmation.
Every name is checked before anything is deleted, so a typo deletes nothing. Pass --yes to skip the confirmation, as scripts must. When several objects share a name, --id picks the one to delete.
Examples
unifi traffic rules delete "Kids bedtime"
unifi traffic rules delete "Kids bedtime" --yesFlags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic rules describe
Show every field of one traffic rule.
Usage
unifi traffic rules describe <description> [flags]Show every field of one traffic rule.
The kinds people look at most are laid out in words, with references shown by name; the others list their fields under the paths that unifi traffic rules set <description> --set <path>=<value> takes. --output yaml always prints the complete object as the controller spells it.
Secrets such as passphrases and keys read <redacted>. --show-secrets prints them in --output yaml and --output json, never in the text view. When several objects share the name, --id picks one.
Examples
unifi traffic rules describe "Kids bedtime"
unifi traffic rules describe "Kids bedtime" --output json
unifi traffic rules describe --id <id>Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
unifi traffic rules disable
Disable a traffic rule.
Usage
unifi traffic rules disable <description> [flags]Disable a traffic rule. It is a shortcut for unifi traffic rules set <description> --set enabled=false.
Examples
unifi traffic rules disable "Kids bedtime"Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic rules edit
Edit a traffic rule in your editor.
Usage
unifi traffic rules edit <description> [flags]Open a traffic rule as a YAML manifest in your editor and apply it on save.
The editor is taken from $VISUAL, then $EDITOR, then vi. What you save becomes the object's new state: removing a field removes it. Closing without changes, or emptying the file, cancels the edit.
Secrets such as passphrases and keys are shown as <redacted>. Leave that as it is to keep a secret, or type a new value over it to change it.
When the result is not a valid manifest or the controller rejects it, your edits are kept in a file whose path is printed, so nothing is lost.
Examples
unifi traffic rules edit "Kids bedtime"
unifi traffic rules edit "Kids bedtime" # with EDITOR="code --wait"Flags
| Flag | Description |
|---|---|
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic rules enable
Enable a traffic rule.
Usage
unifi traffic rules enable <description> [flags]Enable a traffic rule. It is a shortcut for unifi traffic rules set <description> --set enabled=true.
Examples
unifi traffic rules enable "Kids bedtime"Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
-y, --yes | do not ask for confirmation |
unifi traffic rules get
List the traffic rules, or show one.
Usage
unifi traffic rules get [description] [flags]Aliases: list, ls
List the traffic rules of the site, or show the one named by the argument.
--output wide adds columns and the object IDs. --output yaml and --output json print manifests that unifi apply -f - accepts unchanged.
--show-secrets keeps passphrases, keys and other secrets in --output yaml and --output json; without it they read <redacted>, which unifi apply understands as "keep the current value". Tables never show secrets.
--filter takes a filter expression such as enabled && name contains "guest". Fields are the object's own, as shown by --output yaml, plus name and id. --sort takes a column: name, action, matching, enabled, or any field path.
Examples
unifi traffic rules get
unifi traffic rules get --output wide
unifi traffic rules get "Kids bedtime" --output yaml
unifi traffic rules get --filter 'action == "BLOCK"'
unifi traffic rules get --output yaml > traffic-rules.yamlFlags
| Flag | Description |
|---|---|
--filter <string> | filter expression, such as 'enabled && name contains "guest"' |
--id <id> | pick the object by its id, for objects that share a name |
--reverse | reverse the sort order |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
--sort <string> | sort by a column or field path: name, action, matching, enabled |
unifi traffic rules set
Change fields of a traffic rule.
Usage
unifi traffic rules set <description> [flags]Change fields of a traffic rule and show what changed.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list (a list replaces the whole field). --unset path removes a field. --dry-run shows the change without making it.
Find the field paths with unifi traffic rules get <description> --output yaml.
Examples
unifi traffic rules set "Kids bedtime" --enabled=true
unifi traffic rules set "Kids bedtime" --set <path>=<value> --dry-run
unifi traffic rules set "Kids bedtime" --unset <path>Flags
| Flag | Description |
|---|---|
--action <string> | what happens to matching traffic: BLOCK, ALLOW |
--dry-run | show what would change without changing it |
--enabled | whether the rule is active; turn it off with --enabled=false |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
--matching <string> | what the rule matches on, such as INTERNET, APP, APP_CATEGORY, DOMAIN, IP, REGION, LOCAL_NETWORK |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
--unset <path> | clear a field by its path, repeatable: the controller's internal API keeps the key and stores an empty value |
-y, --yes | do not ask for confirmation |
Global flags
These flags are accepted by every command.
| Flag | Description |
|---|---|
--color-scheme <string> | color scheme: auto, dark or light |
--context <string> | context to use instead of the current one |
--no-cache | ask the controller for everything instead of using cached answers |
-o, --output <string> | output format: text, wide, json, yaml (table is another name for text) |
-s, --site <string> | site to act on instead of the context's default site |
--theme <string> | theme to render with instead of the configured one |
