Netplan template macros

The following table describes the main lookup functions, or macros, that can be used in the npTemplate field of an L2 template.

Lookup function

Description

{{nic N}}

Name of a NIC number N. NIC numbers correspond to the interface mapping list. This macro can be used as a key for the elements of ethernets map, or as the value of name and set-name parameters of a NIC. It is also used to reference the physical NIC from definitions of virtual interfaces (vlan, bridge).

{{mac N}}

MAC address of a NIC number N registered during a host hardware inspection.

{{ip "N:subnet-a"}}

IP address and mask for a NIC number N. The address will be allocated automatically from the given subnet, unless an IP address for that interface already exists. The interface is identified by its MAC address.

{{ip "br0:subnet-x"}}

IP address and mask for a virtual interface, "br0" in this example. The address will be auto-allocated from the given subnet if the address does not exist yet.

{{gateway_from_subnet "subnet-a"}}

IPv4 default gateway address from the given subnet.

{{nameservers_from_subnet "subnet-a"}}

List of the IP addresses of name servers from the given subnet.