Blame doc/rtd/topics/network-config.rst

Packit Service a04d08
*********************
Packit Service a04d08
Network Configuration
Packit Service a04d08
*********************
Packit Service a04d08
Packit Service a04d08
- Default Behavior
Packit Service a04d08
- Disabling Network Configuration
Packit Service a04d08
- Fallback Networking
Packit Service a04d08
- Network Configuration Sources
Packit Service a04d08
- Network Configuration Outputs
Packit Service a04d08
- Network Output Policy
Packit Service a04d08
- Network Configuration Tools
Packit Service a04d08
- Examples
Packit Service a04d08
Packit Service a04d08
.. _default_behavior:
Packit Service a04d08
Packit Service a04d08
Default Behavior
Packit Service a04d08
================
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ 's searches for network configuration in order of increasing
Packit Service a04d08
precedence; each item overriding the previous.
Packit Service a04d08
Packit Service a04d08
**Datasource**
Packit Service a04d08
Packit Service a04d08
For example, OpenStack may provide network config in the MetaData Service.
Packit Service a04d08
Packit Service a04d08
**System Config**
Packit Service a04d08
Packit Service 751c4a
A ``network:`` entry in ``/etc/cloud/cloud.cfg.d/*`` configuration files.
Packit Service a04d08
Packit Service a04d08
**Kernel Command Line**
Packit Service a04d08
Packit Service 751c4a
``ip=`` or ``network-config=<Base64 encoded YAML config string>``
Packit Service a04d08
Packit Service a04d08
User-data cannot change an instance's network configuration.  In the absence
Packit Service a04d08
of network configuration in any of the above sources , `Cloud-init`_ will
Packit Service a04d08
write out a network configuration that will issue a DHCP request on a "first"
Packit Service a04d08
network interface.
Packit Service a04d08
Packit Service 751c4a
.. note::
Packit Service 751c4a
Packit Service 751c4a
  The network-config value is expected to be a Base64 encoded YAML string in
Packit Service 751c4a
  :ref:`network_config_v1` or :ref:`network_config_v2` format. Optionally it
Packit Service 751c4a
  can be compressed with ``gzip`` prior to Base64 encoding.
Packit Service 751c4a
Packit Service a04d08
Packit Service a04d08
Disabling Network Configuration
Packit Service a04d08
===============================
Packit Service a04d08
Packit Service a04d08
Users may disable `Cloud-init`_ 's network configuration capability and rely
Packit Service a04d08
on other methods, such as embedded configuration or other customizations.
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ supports the following methods for disabling cloud-init.
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
**Kernel Command Line**
Packit Service a04d08
Packit Service 751c4a
`Cloud-init`_ will check additionally check for the parameter
Packit Service 751c4a
``network-config=disabled`` which will automatically disable any network
Packit Service 751c4a
configuration.
Packit Service a04d08
Packit Service a04d08
Example disabling kernel command line entry: ::
Packit Service a04d08
Packit Service 751c4a
  network-config=disabled
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
**cloud config**
Packit Service a04d08
Packit Service 751c4a
In the combined cloud-init configuration dictionary, merged from
Packit Service 751c4a
``/etc/cloud/cloud.cfg`` and ``/etc/cloud/cloud.cfg.d/*``::
Packit Service a04d08
Packit Service a04d08
  network:
Packit Service a04d08
    config: disabled
Packit Service a04d08
Packit Service a04d08
If `Cloud-init`_ 's networking config has not been disabled, and
Packit Service a04d08
no other network information is found, then it will proceed
Packit Service a04d08
to generate a fallback networking configuration.
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
Fallback Network Configuration
Packit Service a04d08
==============================
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ will attempt to determine which of any attached network devices
Packit Service a04d08
is most likely to have a connection and then generate a network
Packit Service a04d08
configuration to issue a DHCP request on that interface.
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ runs during early boot and does not expect composed network
Packit Service a04d08
devices (such as Bridges) to be available.  `Cloud-init`_ does not consider
Packit Service a04d08
the following interface devices as likely 'first' network interfaces for
Packit Service a04d08
fallback configuration; they are filtered out from being selected.
Packit Service a04d08
Packit Service a04d08
- **loopback**: ``name=lo``
Packit Service a04d08
- **Virtual Ethernet**: ``name=veth*``
Packit Service a04d08
- **Software Bridges**: ``type=bridge``
Packit Service a04d08
- **Software VLANs**: ``type=vlan``
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ will prefer network interfaces that indicate they are connected
Packit Service a04d08
via the Linux ``carrier`` flag being set.  If no interfaces are marked
Packit Service a04d08
connected, then all unfiltered interfaces are potential connections.
Packit Service a04d08
Packit Service a04d08
Of the potential interfaces, `Cloud-init`_ will attempt to pick the "right"
Packit Service a04d08
interface given the information it has available.
Packit Service a04d08
Packit Service a04d08
Finally after selecting the "right" interface, a configuration is
Packit Service a04d08
generated and applied to the system.
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
Network Configuration Sources
Packit Service a04d08
=============================
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ accepts a number of different network configuration formats in
Packit Service a04d08
support of different cloud substrates.  The Datasource for these clouds in
Packit Service a04d08
`Cloud-init`_ will detect and consume Datasource-specific network
Packit Service a04d08
configuration formats for use when writing an instance's network
Packit Service a04d08
configuration.
Packit Service a04d08
Packit Service a04d08
The following Datasources optionally provide network configuration:
Packit Service a04d08
Packit Service a04d08
- :ref:`datasource_config_drive`
Packit Service a04d08
Packit Service a04d08
  - `OpenStack Metadata Service Network`_
Packit Service a04d08
  - :ref:`network_config_eni`
Packit Service a04d08
Packit Service a04d08
- :ref:`datasource_digital_ocean`
Packit Service a04d08
Packit Service a04d08
  - `DigitalOcean JSON metadata`_
Packit Service a04d08
Packit Service a04d08
- :ref:`datasource_nocloud`
Packit Service a04d08
Packit Service a04d08
  - :ref:`network_config_v1`
Packit Service a04d08
  - :ref:`network_config_v2`
Packit Service a04d08
  - :ref:`network_config_eni`
Packit Service a04d08
Packit Service a04d08
- :ref:`datasource_opennebula`
Packit Service a04d08
Packit Service a04d08
  - :ref:`network_config_eni`
Packit Service a04d08
Packit Service a04d08
- :ref:`datasource_openstack`
Packit Service a04d08
Packit Service a04d08
  - :ref:`network_config_eni`
Packit Service a04d08
  - `OpenStack Metadata Service Network`_
Packit Service a04d08
Packit Service a04d08
- :ref:`datasource_smartos`
Packit Service a04d08
Packit Service a04d08
  - `SmartOS JSON Metadata`_
Packit Service a04d08
Packit Service a04d08
For more information on network configuration formats
Packit Service a04d08
Packit Service a04d08
.. toctree::
Packit Service a04d08
  :maxdepth: 1
Packit Service a04d08
Packit Service a04d08
  network-config-format-eni.rst
Packit Service a04d08
  network-config-format-v1.rst
Packit Service a04d08
  network-config-format-v2.rst
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
Network Configuration Outputs
Packit Service a04d08
=============================
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ converts various forms of user supplied or automatically
Packit Service a04d08
generated configuration into an internal network configuration state. From
Packit Service a04d08
this state `Cloud-init`_ delegates rendering of the configuration to Distro
Packit Service a04d08
supported formats.  The following ``renderers`` are supported in cloud-init:
Packit Service a04d08
Packit Service a04d08
- **ENI**
Packit Service a04d08
Packit Service a04d08
/etc/network/interfaces or ``ENI`` is supported by the ``ifupdown`` package
Packit Service 751c4a
found in Alpine Linux, Debian and Ubuntu.
Packit Service a04d08
Packit Service a04d08
- **Netplan**
Packit Service a04d08
Packit Service a04d08
Introduced in Ubuntu 16.10 (Yakkety Yak), `netplan <https://netplan.io/>`_ has
Packit Service a04d08
been the default network configuration tool in Ubuntu since 17.10 (Artful
Packit Service a04d08
Aardvark).  netplan consumes :ref:`network_config_v2` input and renders
Packit Service a04d08
network configuration for supported backends such as ``systemd-networkd`` and
Packit Service a04d08
``NetworkManager``.
Packit Service a04d08
Packit Service a04d08
- **Sysconfig**
Packit Service a04d08
Packit Service a04d08
Sysconfig format is used by RHEL, CentOS, Fedora and other derivatives.
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
Network Output Policy
Packit Service a04d08
=====================
Packit Service a04d08
Packit Service a04d08
The default policy for selecting a network ``renderer`` in order of preference
Packit Service a04d08
is as follows:
Packit Service a04d08
Packit Service a04d08
- ENI
Packit Service a04d08
- Sysconfig
Packit Service a04d08
- Netplan
Packit Service a04d08
Packit Service a04d08
When applying the policy, `Cloud-init`_ checks if the current instance has the
Packit Service a04d08
correct binaries and paths to support the renderer.  The first renderer that
Packit Service a04d08
can be used is selected.  Users may override the network renderer policy by
Packit Service a04d08
supplying an updated configuration in cloud-config. ::
Packit Service a04d08
Packit Service a04d08
  system_info:
Packit Service a04d08
    network:
Packit Service 751c4a
      renderers: ['netplan', 'eni', 'sysconfig', 'freebsd', 'netbsd', 'openbsd']
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
Network Configuration Tools
Packit Service a04d08
===========================
Packit Service a04d08
Packit Service a04d08
`Cloud-init`_ contains one tool used to test input/output conversion between
Packit Service a04d08
formats.  The ``tools/net-convert.py`` in the `Cloud-init`_ source repository
Packit Service a04d08
is helpful for examining expected output for a given input format.
Packit Service a04d08
Packit Service a04d08
CLI Interface :
Packit Service a04d08
Packit Service a04d08
.. code-block:: shell-session
Packit Service a04d08
Packit Service a04d08
  % tools/net-convert.py --help
Packit Service a04d08
  usage: net-convert.py [-h] --network-data PATH --kind
Packit Service a04d08
                        {eni,network_data.json,yaml} -d PATH [-m name,mac]
Packit Service a04d08
                        --output-kind {eni,netplan,sysconfig}
Packit Service a04d08
Packit Service a04d08
  optional arguments:
Packit Service a04d08
    -h, --help            show this help message and exit
Packit Service a04d08
    --network-data PATH, -p PATH
Packit Service a04d08
    --kind {eni,network_data.json,yaml}, -k {eni,network_data.json,yaml}
Packit Service a04d08
    -d PATH, --directory PATH
Packit Service a04d08
                          directory to place output in
Packit Service a04d08
    -m name,mac, --mac name,mac
Packit Service a04d08
                          interface name to mac mapping
Packit Service a04d08
    --output-kind {eni,netplan,sysconfig}, -ok {eni,netplan,sysconfig}
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
Example output converting V2 to sysconfig:
Packit Service a04d08
Packit Service a04d08
.. code-block:: shell-session
Packit Service a04d08
Packit Service a04d08
  % tools/net-convert.py --network-data v2.yaml --kind yaml \
Packit Service a04d08
      --output-kind sysconfig -d target
Packit Service a04d08
  % cat target/etc/sysconfig/network-scripts/ifcfg-eth*
Packit Service a04d08
  # Created by cloud-init on instance boot automatically, do not edit.
Packit Service a04d08
  #
Packit Service a04d08
  BOOTPROTO=static
Packit Service a04d08
  DEVICE=eth7
Packit Service a04d08
  IPADDR=192.168.1.5/255.255.255.0
Packit Service a04d08
  NM_CONTROLLED=no
Packit Service a04d08
  ONBOOT=yes
Packit Service a04d08
  TYPE=Ethernet
Packit Service a04d08
  USERCTL=no
Packit Service a04d08
  # Created by cloud-init on instance boot automatically, do not edit.
Packit Service a04d08
  #
Packit Service a04d08
  BOOTPROTO=dhcp
Packit Service a04d08
  DEVICE=eth9
Packit Service a04d08
  NM_CONTROLLED=no
Packit Service a04d08
  ONBOOT=yes
Packit Service a04d08
  TYPE=Ethernet
Packit Service a04d08
  USERCTL=no
Packit Service a04d08
Packit Service a04d08
Packit Service a04d08
.. _Cloud-init: https://launchpad.net/cloud-init
Packit Service a04d08
.. _DigitalOcean JSON metadata: https://developers.digitalocean.com/documentation/metadata/#network-interfaces-index
Packit Service a04d08
.. _OpenStack Metadata Service Network: https://specs.openstack.org/openstack/nova-specs/specs/liberty/implemented/metadata-service-network-info.html
Packit Service a04d08
.. _SmartOS JSON Metadata: https://eng.joyent.com/mdata/datadict.html
Packit Service a04d08
Packit Service a04d08
.. vi: textwidth=78