9 Keep the following points in mind before you start configuring interfaces using
12 * IPv4 and IPv6 addresses for an interface can be listed in the same ``iface``
13 section. For examples, see ``/usr/share/doc/python-ifupdown2/examples/``.
15 * Do not use a legacy interface alias. They are only supported for backward
16 compatibility with ``ifupdown``. They do get configured, but ``ifquery`` has
17 problems recognizing them.
19 * ``ifupdown`` only understands interfaces that were configured using
20 ``ifupdown``. Any interfaces created with a command other than ``ifupdown``
21 (like ``brctl``) must be de-configured in the same manner.
23 * Use globs for port lists wherever applicable. Regular expressions work as well,
24 however regular expressions require all matching interfaces to be present in
25 the ``interfaces`` file. And declaring all interfaces in the ``interfaces``
26 file leads to losing all the advantages that built-in interfaces provide.
28 * Extensions to ``ifquery`` help with validation and debugging.
30 * By default, ``ifupdown`` is quiet; use the verbose option ``-v`` when you want
31 to know what is going on when bringing an interface down or up.
37 * `Configuration Files`_
38 * `ifupdown Built-in Interfaces`_
39 * `ifupdown Interface Dependencies`_
40 * `Configuring IP Addresses`_
41 * `Specifying User Commands`_
42 * `Sourcing Interface File Snippets`_
43 * `Using Globs for Port Lists`_
45 * `Using ifquery to Validate and Debug Interface Configurations`_
63 * man ifupdown-addons-interfaces(5)
69 * /etc/network/interfaces
72 ifupdown Built-in Interfaces
73 ============================
75 ``ifupdown`` understands VLAN interfaces and physical interfaces that may appear
76 as dependents. There is no need to list them unless they need the specific
77 configuration or they need to match a regular expression used in the
78 ``interfaces`` file. Use globs to avoid limitations with regular expressions.
80 For example, swp1.100 and swp2.100 below do not need an entry in the
86 address 2001:dad:beef::3/64
87 bridge-ports swp1.100 swp2.100
92 ifupdown Interface Dependencies
93 ===============================
95 ``ifupdown`` understands interface dependency relationships. When ``ifup`` and
96 ``ifdown`` are run with all interfaces, they always run with all interfaces
97 in dependency order. When run with the interface list on the command line, the
98 default behavior is to not run with dependents. But if there are any built-in
99 dependents, they will be brought up or down.
101 To run with dependents when you specify the interface list, use the
102 ``--with-depends`` option. ``--with-depends`` walks through all dependents
103 in the dependency tree rooted at the interface you specify. Consider the
104 following example configuration::
109 bond-slaves swp29 swp30
115 bond-xmit-hash-policy layer3+4
120 bond-slaves swp31 swp32
126 bond-xmit-hash-policy layer3+4
131 bridge-ports bond1.2001 bond2.2001
134 Specifying ``ifup --with-depends br2001`` brings up all dependents: bond1.2001,
135 bond2.2001, bond1, bond2, bond1.2001, bond2.2001, swp29, swp30, swp31, swp32.
137 Similarly, specifying ``ifdown --with-depends br2001`` brings down all
138 dependents: bond1.2001, bond2.2001, bond1, bond2, bond1.2001, bond2.2001, swp29,
141 .. warning:: ``ifdown`` always deletes logical interfaces after bringing them
142 down. Use the ``--admin-state`` option if you only want to administratively
143 bring the interface up or down. In terms of the above example,
144 ``ifdown br2001`` deletes ``br2001``.
146 To guide you through which interfaces will be brought down and up, use the
147 ``--print-dependency`` option to get the list of dependents.
149 Use ``ifup --print-dependency=list -a`` to get the dependency list of all
152 cumulus@switch:~$ sudo ifup --print-dependency=list -a
155 bond0 : ['swp25', 'swp26']
156 bond1 : ['swp29', 'swp30']
157 bond2 : ['swp31', 'swp32']
158 br0 : ['bond1', 'bond2']
159 bond1.2000 : ['bond1']
160 bond2.2000 : ['bond2']
161 br2000 : ['bond1.2000', 'bond2.2000']
162 bond1.2001 : ['bond1']
163 bond2.2001 : ['bond2']
164 br2001 : ['bond1.2001', 'bond2.2001']
173 To print the dependency list of a single interface, use::
175 cumulus@switch:~$ sudo ifup --print-dependency=list br2001
176 br2001 : ['bond1.2001', 'bond2.2001']
177 bond1.2001 : ['bond1']
178 bond2.2001 : ['bond2']
179 bond1 : ['swp29', 'swp30']
180 bond2 : ['swp31', 'swp32']
187 To print the dependency information of an interface in ``dot`` format::
189 cumulus@switch:~$ sudo ifup --print-dependency=dot br2001
190 /* Generated by GvGen v.0.9 (http://software.inl.fr/trac/wiki/GvGen) */
193 node1 [label="br2001"];
194 node2 [label="bond1.2001"];
195 node3 [label="bond2.2001"];
196 node4 [label="bond1"];
197 node5 [label="bond2"];
198 node6 [label="swp29"];
199 node7 [label="swp30"];
200 node8 [label="swp31"];
201 node9 [label="swp32"];
212 You can use ``dot`` to render the graph on an external system where ``dot`` is
215 .. image:: images/interfaces.png
218 To print the dependency information of the entire ``interfaces`` file::
220 cumulus@switch:~$ sudo ifup --print-dependency=dot -a >interfaces_all.dot
222 .. image:: images/interfaces_all.png
226 .. note: The '--print-dependency' option is available with the ``ifup``,
227 ``ifdown`` and ``ifquery`` commands.
230 Configuring IP Addresses
231 ========================
233 In ``/etc/network/interfaces``, list all IP addresses as shown below under the
234 ``iface`` section (see ``man interfaces`` for more information)::
241 The address method and address family are not mandatory. They default to
242 ``inet``/``inet6`` and ``static`` by default, but ``inet``/``inet6`` **must** be
243 specified if you need to specify ``dhcp`` or ``loopback``.
245 You can specify both IPv4 and IPv6 addresses under the same ``iface`` section::
251 address 2001:dee:eeef:2::1/64
253 Specifying User Commands
254 ========================
256 You can specify additional user commands in the ``interfaces`` file. As shown in
257 the example below, the interface stanzas in ``/etc/network/interfaces`` can have
258 a command that runs at pre-up, up, post-up, pre-down, down, and post-down::
265 Any valid command can be hooked in the sequencing of bringing an interface up or
266 down, although commands should be limited in scope to network-related commands
267 associated with the particular interface.
269 For example, it wouldn't make sense to install some Debian package on ``ifup``
270 of swp1, even though that is technically possible. See ``man interfaces`` for
273 Sourcing Interface File Snippets
274 ================================
276 Sourcing interface files helps organize and manage the ``interfaces(5)`` file.
279 cumulus@switch:~$ cat /etc/network/interfaces
280 # The loopback network interface
282 iface lo inet loopback
284 # The primary network interface
288 source /etc/network/interfaces.d/bond0
291 The contents of the sourced file used above are::
293 cumulus@switch:~$ cat /etc/network/interfaces.d/bond0
297 address 2001:ded:beef:2::1/64
298 bond-slaves swp25 swp26
304 bond-xmit-hash-policy layer3+4
306 Using Globs for Port Lists
307 ==========================
309 Some modules support globs to describe port lists. You can use globs to specify
310 bridge ports and bond slaves::
314 bridge-ports glob swp1-6.100
318 bridge-ports glob swp7-9.100 swp11.100 glob swp15-18.100
323 ``ifupdown2`` supports Mako-style templates. For more information see
324 `www.makotemplates.org <http://www.makotemplates.org/>`_. The Mako template
325 engine is run over the ``interfaces`` file before parsing.
327 Use the template to declare cookie-cutter bridges in the ``interfaces`` file::
332 address 10.20.${v}.3/24
333 bridge-ports glob swp19-20.${v}
338 And use it to declare addresses in the ``interfaces`` file::
343 address 10.20.${i}.3/24
346 Using ifquery to Validate and Debug Interface Configurations
347 ============================================================
349 You use ``ifquery`` to print parsed ``interfaces`` file entries.
351 To use ``ifquery`` to pretty print ``iface`` entries from the ``interfaces``
354 cumulus@switch:~$ sudo ifquery bond0
358 address 2001:ded:beef:2::1/64
359 bond-slaves swp25 swp26
365 bond-xmit-hash-policy layer3+4
367 .. Use ``ifquery -a`` to pretty print all ``iface`` entries from the
370 Use ``ifquery --check`` to check the current running state of an interface within
371 the ``interfaces`` file. It returns exit code ``0`` or ``1`` if the configuration
374 cumulus@switch:~$ sudo ifquery --check bond0
376 bond-mode 802.3ad (✓)
378 bond-use-carrier 1 (✓)
381 bond-xmit-hash-policy layer3+4 (✓)
382 bond-slaves swp25 swp26 (✓)
383 address 14.0.0.9/30 (✓)
384 address 2001:ded:beef:2::1/64 (✓)
386 .. note:: ``ifquery --check`` is an experimental feature.
388 .. Use ``ifquery --check -a`` to check all interfaces.
390 Use ``ifquery --running`` to print the running state of interfaces in the
391 ``interfaces`` file format::
393 cumulus@switch:~$ sudo ifquery --running bond0
396 bond-xmit-hash-policy layer3+4
400 bond-slaves swp25 swp26
403 address 2001:ded:beef:2::1/64
406 ``ifquery --syntax-help`` provides help on all possible attributes supported in
407 the ``interfaces`` file. For complete syntax on the ``interfaces`` file, see
408 ``man interfaces`` and ``man ifupdown-addons-interfaces``.
410 ``ifquery`` can dump information in JSON format::
412 cumulus@switch:~$ sudo ifquery --format=json bond0
416 "bond-use-carrier": "1",
417 "bond-xmit-hash-policy": "layer3+4",
418 "bond-miimon": "100",
419 "bond-lacp-rate": "1",
420 "bond-min-links": "1",
421 "bond-slaves": "swp25 swp26",
422 "bond-mode": "802.3ad",
425 "2001:ded:beef:2::1/64"
433 .. By default ``ifquery`` outputs information in the ``interfaces`` format. Some
434 options do take the ``--format`` option and can output in JSON format.
440 * `<http://wiki.debian.org/NetworkConfiguration>`_
441 * `<http://www.linuxfoundation.org/collaborate/workgroups/networking/bonding>`_
442 * `<http://www.linuxfoundation.org/collaborate/workgroups/networking/bridge>`_
443 * `<http://www.linuxfoundation.org/collaborate/workgroups/networking/vlan>`_
445 .. Caveats and Errata
446 .. ==================