The ovs-vsctl program configures ovs-vswitchd(8) by
providing a high-level interface to its configuration
database. This program is mainly intended for use when
ovs-vswitchd is running. If it is used when
ovs-vswitchd is not running, then --no-wait should be
specified and configuration changes will only take effect when
ovs-vswitchd is started.
By default, each time ovs-vsctl runs, it connects to an
ovsdb-server process that maintains an Open vSwitch
configuration database. Using this connection, it queries and
possibly applies changes to the database, depending on the supplied
commands. Then, if it applied any changes, it waits until
ovs-vswitchd has finished reconfiguring itself before it exits.
ovs-vsctl can perform any number of commands in a single run,
implemented as a single atomic transaction against the database.
The ovs-vsctl command line begins with global options (see
OPTIONS below for details). The global options are followed by
one or more commands. Each command should begin with -- by
itself as a command-line argument, to separate it from the global
options and following commands. (If the first command does not have
any options, then the first -- may be omitted.) The command
itself starts with command-specific options, if any, followed by the
command name and any arguments. See EXAMPLES below for syntax
examples.
Linux VLAN Bridging Compatibility
The ovs-vsctl program supports the model of a bridge
implemented by Open vSwitch, in which a single bridge supports ports
on multiple VLANs. In this model, each port on a bridge is either a
trunk port that potentially passes packets tagged with 802.1Q headers
that designate VLANs or it is assigned a single implicit VLAN that is
never tagged with an 802.1Q header.
For compatibility with software designed for the Linux bridge,
ovs-vsctl also supports a model in which traffic associated
with a given 802.1Q VLAN is segregated into a separate bridge. A
special form of the add-br command (see below) creates a ``fake
bridge'' within an Open vSwitch bridge to simulate this behavior.
When such a ``fake bridge'' is active, ovs-vsctl will treat it
much like a bridge separate from its ``parent bridge,'' but the actual
implementation in Open vSwitch uses only a single bridge, with ports on
the fake bridge assigned the implicit VLAN of the fake bridge of which
they are members.
OPTIONS
The following options affect the behavior ovs-vsctl as a whole.
Some individual commands also accept their own options, which are
given just before the command name. If the first command on the
command line has options, then those options must be separated from
the global options by --.
--db=server
Sets server as the database server that ovs-vsctl
contacts to query or modify configuration. The default is
unix:/var/run/openvswitch/db.sock. server must take one of the
following forms:
ssl:ip:port
The specified SSL port on the host at the given ip, which
must be expressed as an IP address (not a DNS name). The
--private-key, --certificate, and --ca-cert
options are mandatory when this form is used.
tcp:ip:port
Connect to the given TCP port on ip.
unix:file
Connect to the Unix domain server socket named file.
pssl:port[:ip]
Listen on the given SSL port for a connection. By default,
ovs-vsctl listens for connections to any local IP address, but
specifying ip limits connections to those from the given
ip. The --private-key, --certificate, and
--ca-cert options are mandatory when this form is used.
ptcp:port[:ip]
Listen on the given TCP port for a connection. By default,
ovs-vsctl listens for connections to any local IP address, but
ip may be specified to listen only for connections to the given
ip.
punix:file
Listen on the Unix domain server socket named file for a
connection.
--no-wait
Prevents ovs-vsctl from waiting for ovs-vswitchd to
reconfigure itself according to the the modified database. This
option should be used if ovs-vswitchd is not running;
otherwise, ovs-vsctl will not exit until ovs-vswitchd
starts.
This option has no effect if the commands specified do not change the
database.
--no-syslog
By default, ovs-vsctl logs its arguments and the details of any
changes that it makes to the system log. This option disables this
logging.
This option is equivalent to --verbose=vvsctl:syslog:warn.
--oneline
Modifies the output format so that the output for each command is printed
on a single line. New-line characters that would otherwise separate
lines are printed as \n, and any instances of \ that
would otherwise appear in the output are doubled.
Prints a blank line for each command that has no output.
--dry-run
Prevents ovs-vsctl from actually modifying the database.
-t secs
--timeout=secs
By default, or with a secs of 0, ovs-vsctl waits
forever for a response from the database. This option limits runtime
to approximately secs seconds. If the timeout expires,
ovs-vsctl will exit with a SIGALRM signal. (A timeout
would normally happen only if the database cannot be contacted, or if
the system is overloaded.)
Public Key Infrastructure Options
-pprivkey.pem
--private-key=privkey.pem
Specifies a PEM file containing the private key used as ovs-vsctl's
identity for outgoing SSL connections.
-ccert.pem
--certificate=cert.pem
Specifies a PEM file containing a certificate that certifies the
private key specified on -p or --private-key to be
trustworthy. The certificate must be signed by the certificate
authority (CA) that the peer in SSL connections will use to verify it.
-Ccacert.pem
--ca-cert=cacert.pem
Specifies a PEM file containing the CA certificate that ovs-vsctl
should use to verify certificates presented to it by SSL peers. (This
may be the same certificate that SSL peers use to verify the
certificate specified on -c or --certificate, or it may
be a different one, depending on the PKI design in use.)
-C none
--ca-cert=none
Disables verification of certificates presented by SSL peers. This
introduces a security risk, because it means that certificates cannot
be verified to be those of known trusted hosts.
--bootstrap-ca-cert=cacert.pem
When cacert.pem exists, this option has the same effect as
-C or --ca-cert. If it does not exist, then
ovs-vsctl will attempt to obtain the CA certificate from the
SSL peer on its first SSL connection and save it to the named PEM
file. If it is successful, it will immediately drop the connection
and reconnect, and from then on all SSL connections must be
authenticated by a certificate signed by the CA certificate thus
obtained.
This option exposes the SSL connection to a man-in-the-middle
attack obtaining the initial CA certificate, but it may be useful
for bootstrapping.
This option is only useful if the SSL peer sends its CA certificate as
part of the SSL certificate chain. The SSL protocol does not require
the server to send the CA certificate, but
ovsdb-server(8) can be configured to do so with the
--peer-ca-cert option.
This option is mutually exclusive with -C and
--ca-cert.
--peer-ca-cert=peer-cacert.pem
Specifies a PEM file that contains one or more additional certificates
to send to SSL peers. peer-cacert.pem should be the CA
certificate used to sign ovs-vsctl's own certificate, that is, the
certificate specified on -c or --certificate. If
ovs-vsctl's certificate is self-signed, then --certificate
and --peer-ca-cert should specify the same file.
This option is not useful in normal operation, because the SSL peer
must already have the CA certificate for the peer to have any
confidence in ovs-vsctl's identity. However, this offers a way for
a new installation to bootstrap the CA certificate on its first SSL
connection.
Sets the logging level for module in facility to
level:
•
module may be any valid module name (as displayed by the
--list action on ovs-appctl(8)), or the special name
ANY to set the logging levels for all modules.
•
facility may be syslog, console, or file to
set the levels for logging to the system log, the console, or a file
respectively, or ANY to set the logging levels for both
facilities. If it is omitted, facility defaults to ANY.
Regardless of the log levels set for file, logging to a file
will not take place unless --log-file is also specified (see
below).
•
level must be one of emer, err, warn,
info, or
dbg, designating the minimum severity of a message for it to be
logged. If it is omitted, level defaults to dbg.
-v, --verbose
Sets the maximum logging verbosity level, equivalent to
--verbose=ANY:ANY:dbg.
Sets the log pattern for facility to pattern. Refer to
ovs-appctl(8) for a description of the valid syntax for pattern.
--log-file[=file]
Enables logging to a file. If file is specified, then it is
used as the exact name for the log file. The default log file name
used if file is omitted is /var/log/openvswitch/ovs-vsctl.log.
COMMANDS
The commands implemented by ovs-vsctl are described in the
sections below.
Open vSwitch Commands
These commands work with an Open vSwitch as a whole.
init
Initializes the Open vSwitch database, if it is empty. If the
database has already been initialized, this command has no effect.
Any successful ovs-vsctl command automatically initializes the
Open vSwitch database if it is empty. This command is provided to
initialize the database without executing any other command.
emer-reset
Reset the configuration into a clean state. It deconfigures OpenFlow
controllers, OVSDB servers, and SSL, and deletes port mirroring,
NetFlow, and sFlow configuration. This command also removes all
other-config keys from all database records, except that
other-config:hwaddr is preserved if it is present in a Bridge
record. Other networking configuration is left as-is.
Bridge Commands
These commands examine and manipulate Open vSwitch bridges.
[--may-exist] add-br bridge
Creates a new bridge named bridge. Initially the bridge will
have no ports (other than bridge itself).
Without --may-exist, attempting to create a bridge that
exists is an error. With --may-exist, bridge may
already exist (but it must be a real bridge, not a VLAN bridge).
[--may-exist] add-br bridge parent vlan
Creates a ``fake bridge'' named bridge within the existing Open
vSwitch bridge parent, which must already exist and must not
itself be a fake bridge. The new fake bridge will be on 802.1Q VLAN
vlan, which must be an integer between 1 and 4095. Initially
bridge will have no ports (other than bridge itself).
Without --may-exist, attempting to create a bridge that
exists is an error. With --may-exist, bridge may
already exist (but it must have the specified vlan and
parent).
[--if-exists] del-br bridge
Deletes bridge and all of its ports. If bridge is a real
bridge, this command also deletes any fake bridges that were created
with bridge as parent, including all of their ports.
Without --if-exists, attempting to delete a bridge that does
not exist is an error. With --if-exists, attempting to
delete a bridge that does not exist has no effect.
list-br
Lists all existing real and fake bridges on standard output, one per
line.
br-exists bridge
Tests whether bridge exists as a real or fake bridge. If so,
ovs-vsctl exits successfully with exit code 0. If not,
ovs-vsctl exits unsuccessfully with exit code 2.
br-to-vlan bridge
If bridge is a fake bridge, prints the bridge's 802.1Q VLAN as a
decimal integer. If bridge is a real bridge, prints 0.
br-to-parent bridge
If bridge is a fake bridge, prints the name of its parent
bridge. If bridge is a real bridge, print bridge.
br-set-external-id bridge key [value]
Sets or clears an ``external ID'' value on bridge. These values
are intended to identify entities external to Open vSwitch with which
bridge is associated, e.g. the bridge's identifier in a
virtualization management platform. The Open vSwitch database schema
specifies well-known key values, but key and value
are otherwise arbitrary strings.
If value is specified, then key is set to value for
bridge, overwriting any previous value. If value is
omitted, then key is removed from bridge's set of external
IDs (if it was present).
For real bridges, the effect of this command is similar to that of a
set or remove command in the external-ids column of
the Bridge table. For fake bridges, it actually modifies keys
with names prefixed by fake-bridge- in the Port table.
br-get-external-id bridge [key]
Queries the external IDs on bridge. If key is specified,
the output is the value for that key or the empty string if
key is unset. If key is omitted, the output is
key=value, one per line, for each key-value pair.
For real bridges, the effect of this command is similar to that of a
get command in the external-ids column of the
Bridge table. For fake bridges, it queries keys with names
prefixed by fake-bridge- in the Port table.
Port Commands
These commands examine and manipulate Open vSwitch ports. These
commands treat a bonded port as a single entity.
list-ports bridge
Lists all of the ports within bridge on standard output, one per
line. The local port bridge is not included in the list.
[--may-exist] add-port bridge port [column[:key]=value]...
Creates on bridge a new port named port from the network
device of the same name.
Optional arguments set values of column in the Port record created by
the command. For example, tag=9 would make the port an access
port for VLAN 9. The syntax is the same as that for the set
command (see Database Commands below).
Without --may-exist, attempting to create a port that exists
is an error. With --may-exist, port may already exist
(but it must be on bridge and not be a bonded port).
[--fake-iface] add-bond bridge port iface... [column[:key]=value]...
Creates on bridge a new port named port that bonds
together the network devices given as each iface. At least two
interfaces must be named.
Optional arguments set values of column in the Port record created by
the command. The syntax is the same as that for the set command
(see Database Commands below).
With --fake-iface, a fake interface with the name port is
created. This should only be used for compatibility with legacy
software that requires it.
Without --may-exist, attempting to create a port that exists
is an error. With --may-exist, port may already exist
(but it must be on bridge and bond together exactly the
specified interface).
[--if-exists] del-port [bridge] port
Deletes port. If bridge is omitted, port is removed
from whatever bridge contains it; if bridge is specified, it
must be the real or fake bridge that contains port.
Without --if-exists, attempting to delete a port that does
not exist is an error. With --if-exists, attempting to
delete a port that does not exist has no effect.
Deletes the port named iface or that has an interface named
iface. If bridge is omitted, the port is removed from
whatever bridge contains it; if bridge is specified, it must be
the real or fake bridge that contains the port.
Without --if-exists, attempting to delete the port for an
interface that does not exist is an error. With --if-exists,
attempting to delete the port for an interface that does not exist has
no effect.
port-to-br port
Prints the name of the bridge that contains port on standard
output.
Interface Commands
These commands examine the interfaces attached to an Open vSwitch
bridge. These commands treat a bonded port as a collection of two or
more interfaces, rather than as a single port.
list-ifaces bridge
Lists all of the interfaces within bridge on standard output,
one per line. The local port bridge is not included in the
list.
iface-to-br iface
Prints the name of the bridge that contains iface on standard
output.
OpenFlow Controller Connectivity
ovs-vswitchd can perform all configured bridging and switching
locally, or it can be configured to connect a given bridge to one or
more external OpenFlow controllers, such as NOX.
get-controllerbridge
Prints the configured controller target.
del-controllerbridge
Deletes the configured controller target.
set-controllerbridgetarget...
Sets the configured controller target or targets. Each target may
use any of the following forms:
ssl:ip[:port]
The specified SSL port (default: 6633) on the host at the given
ip, which must be expressed as an IP address (not a DNS name).
The --private-key, --certificate, and
--ca-cert options are mandatory when this form is used.
tcp:ip[:port]
The specified TCP port (default: 6633) on the host at the given
ip, which must be expressed as an IP address (not a DNS name).
unix:file
The Unix domain server socket named file.
Controller Failure Settings
When a controller is configured, it is, ordinarily, responsible for
setting up all flows on the switch. Thus, if the connection to
the controller fails, no new network connections can be set up. If
the connection to the controller stays down long enough, no packets
can pass through the switch at all.
If the value is standalone, or if neither of these settings
is set, ovs-vswitchd will take over
responsibility for setting up
flows when no message has been received from the controller for three
times the inactivity probe interval (xxx needs to be exposed). In this mode,
ovs-vswitchd causes the datapath to act like an ordinary
MAC-learning switch. ovs-vswitchd will continue to retry connecting
to the controller in the background and, when the connection succeeds,
it discontinues its standalone behavior.
If this option is set to secure, ovs-vswitchd will not
set up flows on its own when the controller connection fails.
get-fail-modebridge
Prints the configured failure mode.
del-fail-modebridge
Deletes the configured failure mode.
set-fail-modebridgestandalone|secure
Sets the configured failure mode.
SSL Configuration
When ovs-vswitchd is configured to connect over SSL for management or
controller connectivity, the following parameters are required:
private-key
Specifies a PEM file containing the private key used as the virtual
switch's identity for SSL connections to the controller.
certificate
Specifies a PEM file containing a certificate, signed by the
certificate authority (CA) used by the controller and manager, that
certifies the virtual switch's private key, identifying a trustworthy
switch.
ca-cert
Specifies a PEM file containing the CA certificate used to verify that
the virtual switch is connected to a trustworthy controller.
These files are read only once, at ovs-vswitchd startup time. If
their contents change, ovs-vswitchd must be killed and restarted.
These SSL settings apply to all SSL connections made by the virtual
switch.
Sets the SSL configuration. The --bootstrap option is described
below.
CA Certificate Bootstrap
Ordinarily, all of the files named in the SSL configuration must exist
when ovs-vswitchd starts. However, if the --bootstrap
option is given, then ovs-vswitchd will attempt to obtain the
CA certificate from the controller on its first SSL connection and
save it to the named PEM file. If it is successful, it will
immediately drop the connection and reconnect, and from then on all
SSL connections must be authenticated by a certificate signed by the
CA certificate thus obtained.
This option exposes the SSL connection to a man-in-the-middle
attack obtaining the initial CA certificate, but it may be useful
for bootstrapping.
This option is only useful if the controller sends its CA certificate
as part of the SSL certificate chain. The SSL protocol does not
require the controller to send the CA certificate, but
ovs-controller(8) can be configured to do so with the
--peer-ca-cert option.
Database Commands
These commands query and modify the contents of ovsdb tables.
They are a slight abstraction of the ovsdb interface and as such
they operate at a lower level than other ovs-vsctl commands.
Identifying Tables, Records, and Columns
Each of these commands has a table parameter to identify a table
within the database. Many of them also take a record parameter
that identifies a particular record within a table. The record
parameter may be the UUID for a record, and many tables offer
additional ways to identify records. Some commands also take
column parameters that identify a particular field within the
records in a table.
The following tables are currently defined:
Open_vSwitch
Global configuration for an ovs-vswitchd. This table contains
exactly one record, identified by specifying . as the record
name.
Bridge
Configuration for a bridge within an Open vSwitch. Records may be
identified by bridge name.
Port
A bridge port. Records may be identified by port name.
Interface
A network device attached to a port. Records may be identified by
name.
Mirror
A port mirroring configuration attached to a bridge. Records may be
identified by mirror name.
Controller
Configuration for an OpenFlow controller. A controller attached to a
particular bridge may be identified by the bridge's name.
Manager
Configuration for an OVSDB connection. Records may be identified
by target (e.g. tcp:1.2.3.4).
NetFlow
A NetFlow configuration attached to a bridge. Records may be
identified by bridge name.
SSL
The global SSL configuration for ovs-vswitchd. The record
attached to the Open_vSwitch table may be identified by
specifying . as the record name.
sFlow
An sFlow configuration attached to a bridge. Records may be
identified by bridge name.
Monitor
Connectivity Monitoring attached to an interface. Records may be
identified by interface name.
Maintenance_Point
Maintenance Point managed by a Monitor.
Record names must be specified in full and with correct
capitalization. Names of tables and columns are not case-sensitive,
and -- and _ are treated interchangeably. Unique
abbreviations are acceptable, e.g. net or n is sufficient
to identify the NetFlow table.
Database Values
Each column in the database accepts a fixed type of data. The
currently defined basic types, and their representations, are:
integer
A decimal integer in the range -2**63 to 2**63-1, inclusive.
real
A floating-point number.
Boolean
True or false, written true or false, respectively.
string
An arbitrary Unicode string, except that null bytes are not allowed.
Quotes are optional for most strings that begin with an English letter
or underscore and consist only of letters, underscores, hyphens, and
periods. However, true and false and strings that match
the syntax of UUIDs (see below) must be enclosed in double quotes to
distinguish them from other basic types. When double quotes are used,
the syntax is that of strings in JSON, e.g. backslashes may be used to
escape special characters. The empty string must be represented as a
pair of double quotes ("").
UUID
Either a universally unique identifier in the style of RFC 4122,
e.g. f81d4fae-7dec-11d0-a765-00a0c91e6bf6, or an @name
defined by a get or create command within the same ovs-vsctl
invocation.
Multiple values in a single column may be separated by spaces or a
single comma. When multiple values are present, duplicates are not
allowed, and order is not important. Conversely, some database
columns can have an empty set of values, represented as [], and
square brackets may optionally enclose other non-empty sets or single
values as well.
A few database columns are ``maps'' of key-value pairs, where the key
and the value are each some fixed database type. These are specified
in the form key=value, where key and value
follow the syntax for the column's key type and value type,
respectively. When multiple pairs are present (separated by spaces or
a comma), duplicate keys are not allowed, and again the order is not
important. Duplicate values are allowed. An empty map is represented
as {}, and curly braces may be optionally enclose non-empty maps
as well.
Database Command Syntax
list table [record]...
List the values of all columns of each specified record. If no
records are specified, lists all the records in table.
The UUIDs shown for rows created in the same ovs-vsctl
invocation will be wrong.
[--id=@name] [--if-exists] get table record [column[:key]]...
Prints the value of each specified column in the given
record in table. For map columns, a key may
optionally be specified, in which case the value associated with
key in the column is printed, instead of the entire map.
For a map column, without --if-exists it is an error if
key does not exist; with it, a blank line is printed. If
column is not a map column or if key is not specified,
--if-exists has no effect.
If @name is specified, then the UUID for record may be
referred to by that name later in the same ovs-vsctl
invocation in contexts where a UUID is expected.
set table record column[:key]=value...
Sets the value of each specified column in the given
record in table to value. For map columns, a
key may optionally be specified, in which case the value
associated with key in that column is changed (or added, if none
exists), instead of the entire map.
add table record column [key=]value...
Adds the specified value or key-value pair to column in
record in table. If column is a map, then key
is required, otherwise it is prohibited. If key already exists
in a map column, then the current value is not replaced (use the
set command to replace an existing value).
remove table record column value...
remove table record column key...
remove table record column key=value...
Removes the specified values or key-value pairs from column in
record in table. The first form applies to columns that
are not maps: each specified value is removed from the column.
The second and third forms apply to map columns: if only a key
is specified, then any key-value pair with the given key is
removed, regardless of its value; if a value is given then a
pair is removed only if both key and value match.
It is not an error if the column does not contain the specified key or
value or pair.
cleartable record column...
Sets each column in record in table to the empty set
or empty map, as appropriate. This command applies only to columns
that are allowed to be empty.
[--id=@name] createtable column[:key]=value...
Creates a new record in table and sets the initial values of
each column. Columns not explicitly set will receive their
default values. Outputs the UUID of the new row.
If @name is specified, then the UUID for the new row may be
referred to by that name elsewhere in the same ovs-vsctl
invocation in contexts where a UUID is expected. Such references may
precede or follow the create command.
[--if-exists] destroy table record...
Deletes each specified record from table. Unless
--if-exists is specified, each records must exist.
wait-until table record [column[:key]=value]...
Waits until table contains a record named record whose
column equals value or, if key is specified, whose
column contains a key with the specified value. Any
of the operators !=, <, >, <=, or >= may
be substituted for = to test for inequality, less than, greater
than, less than or equal to, or greater than or equal to,
respectively. (Don't forget to escape < or > from
interpretation by the shell.)
If no column[:key]=value arguments are given,
this command waits only until record exists. If more than one
such argument is given, the command waits until all of them are
satisfied.
Usually wait-until should be placed at the beginning of a set
of ovs-vsctl commands. For example, wait-until bridge br0
-- get bridge br0 datapath_id waits until a bridge named
br0 is created, then prints its datapath_id column,
whereas get bridge br0 datapath_id -- wait-until bridge br0
will abort if no bridge named br0 exists when ovs-vsctl
initially connects to the database.
Consider specifying --timeout=0 along with
--wait-until, to prevent ovs-vsctl from terminating
after waiting only at most 5 seconds.
EXAMPLES
Create a new bridge named br0 and add port eth0 to it:
ovs-vsctl add-br br0 ovs-vsctl add-port br0 eth0
Alternatively, perform both operations in a single atomic transaction:
ovs-vsctl add-br br0 -- add-port br0 eth0
Delete bridge br0, reporting an error if it does not exist:
ovs-vsctl del-br br0
Delete bridge br0 if it exists (the -- is required to
separate del-br's options from the global options):
ovs-vsctl -- --if-exists del-br br0
Set the qos column of the Port record for eth0 to
point to a new QoS record, which in turn points with its queue 0
to a new Queue record:
ovs-vsctl -- set port eth0 qos=@newqos -- --id=@newqos create qos type=linux-htb other-config:max-rate=1000000 queues:0=@newqueue -- --id=@newqueue create queue other-config:min-rate=1000000 other-config:max-rate=1000000
CONFIGURATION COOKBOOK
Port Configuration
Add an ``internal port'' vlan10 to bridge br0 as a VLAN
access port for VLAN 10, and configure it with an IP address:
ovs-vsctl add-port br0 vlan10 tag=10 -- set Interface vlan10 type=internal
ifconfig vlan10 192.168.0.123
Port Mirroring
Mirror all packets received or sent on eth0 or eth1 onto
eth2, assuming that all of those ports exist on bridge br0
(as a side-effect this causes any packets received on eth2 to be
ignored):
To deconfigure the QoS record from both eth0 and eth1 and
then delete the QoS record:
ovs-vsctl -- destroy QoS eth0 -- clear Port eth0 qos -- clear Port eth1 qos
(This command will leave two unreferenced Queue records in the
database. To delete them, use "ovs-vsctl list Queue" to find
their UUIDs, then "ovs-vsctl destroy Queue uuid1uuid2" to destroy each of them.)
Connectivity Monitoring
Create a Monitor which manages a couple of remote Maintenance Points on eth0.
Configure bridge br0 to send sFlow records to a collector on
10.0.0.1 at port 6343, using eth1's IP address as the source,
with specific sampling parameters: