Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

Оглавление

Configuring network using netplan

Introduction

In Ubuntu-18.04, the network configuration file is located in the /etc/netplan/ directory (configuration file placement options:{etc|run|lib}/netplan/*.yaml) and has .yaml. extension. Official documentation on all netplan commands and settings is provided on the website.

...

  • netplan apply — apply settings;
  • netplan try — try to apply settings with the possibility of cancellation;
  • netplan ip leases interface — view interface settings (for example, enp3s0);
  • netplan ifupdown-migrate — convert old /etc/network/interfaces settings to netplan format;
  • netplan generate — create a specific configuration from a file with the .yaml extension for a network manager (network-manager or systemd-network). To output debugging messages, use the netplan--debug generate command.

Basic configuration

Configuration example:

Без форматирования
   # /etc/netplan/01-network-manager-all.yaml
    # Let NetworkManager manage all devices on this system
    network:
        version: 2
        renderer: networkd
        ethernets:
            enp3s0:
                addresses: []
                dhcp4: true
                optional: true

...

  • network — start of configuration;
  • version — declaration of the yaml version on which the configuration is presented;
  • renderer — direction for netplan to which program to transfer control to, for example networkd (systemd-network);
  • ethernets — declaration of the physical wired interfaces. It defines the network interfaces that are actually connected. For example, enp3s0.A list of static addresses (one or more) is specified for this interface. dhcp4 is enabled for the IPv4 dhcp client (obtaining IP addresses via dhcp in ecss is unacceptable, disabled by default);
  • optional — parameter that means that there is no need to bide time when starting/rebooting the system in order for the interface to be fully functional. The default value of the parameter is false, only networkd is supported.

Configuring interfaces

General settings for physical interfaces

  • match (mapping) — selection of interfaces by criterion. All defined properties must match to be applied in the configuration;
  • macaddress (scalar) — MAC address of the device;
  • set-name (scalar) — setting a unique interface name;
  • driver (scalar) — specifying the name of the kernel driver, points to the DRIVER udev property. Match is supported only for networkd;
  • wakeonlan (bool) — turning on the computer remotely over the network, works only when MAC address of the device is specified.

General settings for all types

  • renderer (scalar) — backend selection;
  • dhcp4 (bool) — getting network settings via dhcp IPv4;
  • dhcp6 (bool) — getting network settings via dhcp IPv6;
  • addresses (sequence of scalar) — a list of network addresses like a.b.c.d/mask for IPv4 or "2001:1::/64" for IPv6;
  • gateway4 (scalar) — gateway for IPv4;
  • gateway6 (scalar) — gateway for IPv6;
  • nameservers (mapping) — dns configuration;
  • optional (bool) — determining whether the interface is required at startup;
  • routes (mapping) — configuring routing.

Routing

  • vlans: — declaration of the vlan configuration block;
  • vlan1 (as an example): — arbitrary name of the vlan interface;
  • id: — vlan tag;
  • link: — interface through which the vlan will be accessible;
  • routes: — declaration of the route description block;
  • to: — specifies the subnet/mask to which the route is needed;
  • via: — specifies the gateway through which the subnet will be accessible;
  • on-link: — it is indicated that it is necessary to prescribe routes always when raising the link.

Bond (Aggregation)

Bond — aggregation of physical interfaces into logical ones.

...

  • interfaces (sequence of scalar) — a list of physical interfaces that need to be combined into one;
  • parameters (mapping) — aggregation settings.

Parameters block

Below are some parameters of the aggregation mode, the full list is in the official documentation.

...

  • bonds: — block explaining that the bonding configuring will take place;
  • bond-ssw: — arbitrary interface name;
  • interfaces: — set of interfaces assembled in bonding;
  • parameters: — description of the parameter settings block;
  • mode: — specifies the mode by which bonding will work;
  • mii-monitor-interval: — monitoring interval is set to 1 second.

VLAN

Example of virtual interfaces configuration:

...