2018-05-29 21:07:40 +00:00
---
2020-09-01 15:14:13 +00:00
layout: commands
2020-04-06 20:27:35 +00:00
page_title: 'Commands: Intention'
2023-01-26 18:42:13 +00:00
description: >-
The `consul intention` command interacts with service intentions to secure service mesh traffic. It exposes top-level commands for interacting with intentions. It was deprecated in Consul v1.9.0. To interact with intentions, use `consul config` instead.
2018-05-29 21:07:40 +00:00
---
# Consul Intention
Command: `consul intention`
2023-05-05 17:41:40 +00:00
The `intention` command is used to interact with service mesh
2023-01-25 16:52:43 +00:00
[intentions](/consul/docs/connect/intentions). It exposes commands for
2018-05-29 21:07:40 +00:00
creating, updating, reading, deleting, checking, and managing intentions.
This command is available in Consul 1.2 and later.
2023-03-24 22:16:06 +00:00
Use the
[`service-intentions`](/consul/docs/connect/config-entries/service-intentions) configuration entry or the [HTTP
API](/consul/api-docs/connect/intentions) to manage intentions.
2018-05-29 21:07:40 +00:00
2021-10-21 17:29:23 +00:00
~> **Deprecated** - This command is deprecated in Consul 1.9.0 in favor of
2023-01-25 16:52:43 +00:00
using the [config entry CLI command](/consul/commands/config/write). To create an
2021-10-21 17:29:23 +00:00
intention, create or modify a
2023-01-25 16:52:43 +00:00
[`service-intentions`](/consul/docs/connect/config-entries/service-intentions) config
2021-10-21 17:29:23 +00:00
entry for the destination.
2018-05-29 21:07:40 +00:00
## Usage
Usage: `consul intention <subcommand>`
2021-01-12 20:14:31 +00:00
For the exact documentation for your Consul version, run `consul intention -h`
to view the complete list of subcommands.
2018-05-29 21:07:40 +00:00
```text
Usage: consul intention <subcommand> [options] [args]
...
Subcommands:
check Check whether a connection between two services is allowed.
create Create intentions for service connections.
delete Delete an intention.
2021-01-12 20:14:31 +00:00
list Lists all intentions.
2018-05-29 21:07:40 +00:00
get Show information about an intention.
match Show intentions that match a source or destination.
```
For more information, examples, and usage about a subcommand, click on the name
of the subcommand in the sidebar.
## Basic Examples
Create an intention to allow "web" to talk to "db":
2020-05-19 18:32:38 +00:00
```shell-session
2020-04-07 23:56:08 +00:00
$ consul intention create web db
```
2018-05-29 21:07:40 +00:00
2020-05-13 21:29:40 +00:00
Create an intention to deny "db" from initiating connections to _any_ service:
2020-05-19 18:32:38 +00:00
```shell-session
2020-05-13 21:29:40 +00:00
$ consul intention create -deny db '*'
Created: db => * (deny)
```
2018-05-29 21:07:40 +00:00
Test whether a "web" is allowed to connect to "db":
2020-05-19 18:32:38 +00:00
```shell-session
2020-04-07 23:56:08 +00:00
$ consul intention check web db
```
2018-05-29 21:07:40 +00:00
2021-01-12 20:14:31 +00:00
List all intentions:
```shell-session
$ consul intention list
```
2018-05-29 21:07:40 +00:00
Find all intentions for communicating to the "db" service:
2020-05-19 18:32:38 +00:00
```shell-session
2020-04-07 23:56:08 +00:00
$ consul intention match db
```
2020-06-26 21:59:15 +00:00
## Source and Destination Naming
Intention commands commonly take positional arguments referred to as `SRC` and
`DST` in the command documentation. These can take several forms:
2021-12-15 01:55:21 +00:00
| Format | Meaning |
| ----------------------------------- | --------------------------------------------------------------------------------------------- |
| `<service>` | the named service in the current namespace |
| `*` | any service in the current namespace |
| `<namespace>/<service>` | <EnterpriseAlert inline /> the named service in a specific namespace in the default partition |
| `<namespace>/*` | <EnterpriseAlert inline /> any service in the specified namespace in the default partition |
| `*/*` | <EnterpriseAlert inline /> any service in any namespace in the default partition |
| `<partition>/<namespace>/<service>` | <EnterpriseAlert inline /> the named service in a specific namespace |
| `<partition>/<namespace>/*` | <EnterpriseAlert inline /> any service in the specified namespace in a specific partition |
| `<partition>/*/*` | <EnterpriseAlert inline /> any service in any namespace in the a specific partition |