File: interfaces.5.pre

package info (click to toggle)
ifupdown 0.8.44
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 952 kB
  • sloc: ansic: 2,781; sh: 899; perl: 513; makefile: 90
file content (538 lines) | stat: -rw-r--r-- 20,689 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
.\" -*- nroff -*-
.\" macros
.de EX \" Begin Example
.  IP
.  ft CW
.  nf
.  ne \\$1
..
.de EE \" End Example
.  ft P
.  fi
.  PP
..
.TH INTERFACES 5 "24 July 2017" "ifupdown" "File formats"
.SH NAME
/etc/network/interfaces \- network interface configuration for ifup and ifdown
.SH DESCRIPTION
/etc/network/interfaces contains network interface configuration
information for the
.BR ifup (8)
and
.BR ifdown (8)
commands.
This is where you configure how your system is connected to the network.
.SH EXAMPLE
The following example configures two network interfaces: eth0 is brought up at boot, and uses DHCP for IPv4 and SLAAC for IPv6, whereas eth1 is brought up whenever the network hardware is detected, and is configured with static IPv4 and IPv6 addresses.
.P
.EX
auto eth0
allow-hotplug eth1

iface eth0 inet dhcp

iface eth0 inet6 auto

iface eth1 inet static
	address 192.168.1.2/24
	gateway 192.168.1.1

iface eth1 inet6 static
	address fec0:0:0:1::2/64
	gateway fec0:0:0:1::1
.EE
.SH FILE FORMAT
Lines starting with `#' are ignored. Note that end-of-line comments are
NOT supported, comments must be on a line of their own.
.P
A line may be extended across multiple lines by making the last character
a backslash.
.P
The file consists of zero or more "iface", "mapping", "auto", "allow-", "rename",
"source" and "source-directory" stanzas. These will be described in more detail in the following sections.
.SH INTERFACE SELECTION
Lines beginning with the word "auto" are used to identify the physical
interfaces to be brought up when
.B ifup
is run with the
.B \-a
option.  (This option is also used by the system boot scripts, so interfaces marked "auto" are brought up at boot time.)
Physical interface names should follow the word "auto" on the same line.
There can be multiple "auto" stanzas.
.B ifup
brings the named interfaces up in the order listed.
.P
Lines beginning with "allow-" are used to identify interfaces that should
be brought up automatically by various subsystems. This may be done using
a command such as "ifup \-\-allow=hotplug eth0 eth1", which will only bring
up eth0 or eth1 if it is listed in an "allow-hotplug" line. Note that
"allow-auto" and "auto" are synonyms.
(Interfaces marked "allow-hotplug" are brought up when udev detects them.
This can either be during boot if the interface is already present, or at a later time,
for example when plugging in a USB network card.
Please note that this does not have anything to do with detecting a network cable being plugged in.)
.P
Lines beginning with "no-auto-down" are used to identify interfaces that should
not be brought down by the command "ifdown -a". Its main use is to prevent an
interface from being brought down during system shutdown time, for example if
the root filesystem is a network filesystem and the interface should stay up
until the very end. Note that you can still bring down the interface by
specifying the interface name explicitly.
.P
Lines beginning with "no-scripts" are used to identify interfaces for which scripts in
.IR /etc/network/if\-*.d/
should not be run when those interfaces are brought up or down.
he above will match eth0 and eth1, and will bring up both interfaces using the "iface eth" stanza.
.SH INTERFACE RENAMING
Lines beginning with "rename" are used to rename interfaces.
It takes one or more arguments in the form of "CUR=NEW", where CUR is the name of an existing interface, and NEW is the new name.
This becomes very powerful when combined with pattern matching for the CUR interface.
.P
Interfaces are renamed whenever "ifup" is called.
Renaming logically happens before anything else is done.
So if an interface is started with the name "foo", and it has to be renamed to "bar" and brought up at boot time,
then one should use the following /etc/network/interfaces file:
.P
.EX
rename foo=bar
auto bar
iface bar ...
.EE
.P
However, if the interface is not renamed yet, it is possible to use both "ifup foo" and "ifup bar".
The former command will then automatically be converted to the latter.
This is mainly useful when ifup is called automatically whenever an interface is hotplugged.
.P
Interface renaming only works if the operating system supports it,
if an interface is not renamed to another existing interface,
and may require that the interface that is to be renamed has not been brought up yet.
If ifup tries to rename an interface and it fails, it will exit with an error.
.SH INCLUDING OTHER FILES
Lines beginning with "source" are used to include stanzas from other files,
so configuration can be split into many files. The word "source" is
followed by the path of file to be sourced. Shell wildcards can be
used.
(See
.BR wordexp (3)
for details.)
.P
Similarly, "source-directory" keyword is used to source multiple files at once,
without specifying them individually or using shell globs. Additionally,
when "source-directory" is used, names of the files are checked to match
the following regular expression: \fI^[a\-zA\-Z0\-9_\-]+$\fR. In other words,
the names must consist entirely of ASCII upper- and lower-case letters,
ASCII digits, ASCII underscores, and ASCII minus-hyphens. In the directory path,
shell wildcards may be used as well.
.P
When sourcing files or directories, if a path doesn't have a leading slash,
it's considered relative to the directory containing the file in which the
keyword is placed. In the example above, if the file is located at
.IR /etc/network/interfaces\fR,
paths to the included files are understood to be under
.IR /etc/network\fR.
.P
By default, on a freshly installed Debian system, the interfaces file includes a
line to source files in the
.IR /etc/network/interfaces.d
directory.
.SH MAPPINGS
Stanzas beginning with the word "mapping" are used to determine how a
logical interface name is chosen for a physical interface that is to be
brought up.  The first line of a mapping stanza consists of the word
"mapping" followed by a pattern in shell glob syntax.  Each mapping stanza
must contain a
.BR script
definition.  The named script is run with the physical interface name as
its argument and with the contents of all following "map" lines
(\fBwithout\fR the leading "map") in the
stanza provided to it on its standard input. The script must print a
string on its standard output before exiting. See
.IR /usr/share/doc/ifupdown/examples
for examples of what the script must print.
.P
Mapping a name consists of searching the remaining mapping
patterns and running the script corresponding to the first match;
the script outputs the name to which the original is mapped.
.P
.B ifup
is normally given a physical interface name as its first non\-option argument.
.B ifup
also uses this name as the initial logical name for the interface unless
it is accompanied by a  suffix of the form \fI=LOGICAL\fR, in which case
ifup chooses \fILOGICAL\fR as the initial logical name for the interface.
It then maps this name, possibly more than once according to successive
mapping specifications,  until no further mappings are possible.  If the
resulting name is the name of some defined logical interface then
.B ifup
attempts to bring up the physical interface
as that logical interface.  Otherwise
.B ifup
exits with an error.
.SH INTERFACE DEFINITIONS
Stanzas defining logical interfaces start with a line consisting of the
word "iface" followed by the name of the logical interface.
In simple configurations without mapping stanzas this name should simply
be the name of the physical interface to which it is to be applied.
(The default mapping script is, in effect, the
.B echo
command.)
The interface name is followed by the name of the address family that the
interface uses.  This will be "inet" for TCP/IP networking, but there is
also some support for IPX networking ("ipx"), and IPv6 networking ("inet6").
Following that is the name of the method used to configure the interface.
.P
Additional options can be given on subsequent lines in the stanza.
Which options are available depends on the family and method,
as described below.
Additional options can be made available by other Debian packages.
For example, the wireless\-tools package makes available a number of
options prefixed with "wireless\-" which can be used to configure the
interface using
.BR iwconfig (8) .
(See
.BR wireless (7)
for details.)
A list of packages providing additional options is mentioned in the section "OPTIONS PROVIDED BY OTHER PACKAGE".
.P
Options are usually indented for clarity (as in the example above)
but are not required to be.
.P
Multiple "iface" stanzas can be given for the same interface, in which case all
of the configured addresses and options for that interface will be applied when
bringing up that interface.  This is useful to configure both IPv4 and IPv6
addresses on the same interface (although if no inet6 stanza is present, the
kernel will normally still perform stateless address autoconfiguration if there
is an IPv6 route advertisement daemon on the network). It can also be used to
configure multiple addresses of the same type on a single interface.
.P
.SH INTERFACE TEMPLATES
It is possible to define interface definition templates and extend
them using the
.B inherits
keyword:
.P
.EX
iface ethernet inet static
	mtu 1500
	hwaddress 11:22:33:44:55:66

iface eth0 inet static inherits ethernet
	address 192.168.1.2/24
.EE
.P
This may be useful to separate link-level settings shared by multiple
interfaces from, for example, IP address settings specific to every
interface.
.SH PATTERN MATCHING INTERFACES
It is possible to use patterns to match one or more real interfaces.
These patterns can currently appear in lines beginning with "auto", "allow-", "rename" and on the command line.
A pattern has the following format (see below for exceptions for GNU/Hurd):
.P
.EX
[VARIABLE]/VALUE[/[OPTIONS]][=LOGICAL]
.EE
.P
If no VARIABLE is given, this pattern will match interface names against the given VALUE.
VALUE can contain wildcard patterns such as ? and *,
see the
.BR fnmatch (3)
function.
When
.BR ifup
or
.BR ifdown
is run, patterns are replaces by all real interfaces that are currently known to the operating system kernel and whose names match the pattern.
For example, given the following line:
.P
.EX
auto /eth*
.EE
.P
If the kernel knows about the interfaces with names lo, eth0 and eth1,
then the above line is then interpreted as:
.P
.EX
auto eth0 eth1
.EE
.P
Note that there must still be valid "iface" stanzas for each matching interface.
However, it is possible to combine a pattern with a mapping to a logical interface, like so:
.P
.EX
auto /eth*=eth
iface eth inet dhcp
.EE
.P
Valid variable names are "mac", in which case value is matched against the interface's MAC address.
On Linux, the variable name can also be any filename in /sys/class/net/<iface>/,
in which case the value is matched against the contents of the corresponding file.
.P
The OPTIONS field currently only supports a number. If given, only the n-th interface that has a matching value will actually be used, where n is the number given, starting at 1. So /eth*/1 will match the first interface whose name starts with eth.
.P
On GNU/Hurd, interface names start with /dev/, and this obviously clashes with the format for patterns.
To ensure an interface name like /dev/eth0 does not get interpreted as a pattern,
any pattern that starts with /dev/ is ignored, and instead interpreted as a literal interface name.
To make a pattern that matches interface names on GNU/Hurd, use something like:
.P
.EX
auto /?dev?eth*=eth
iface eth inet dhcp
.EE
.SH VLAN INTERFACES
To ease the configuration of VLAN interfaces, interfaces having
.B .
(full stop character) in the name are configured as 802.1q tagged
virtual LAN interface. For example, interface
.B eth0.1
is a virtual interface with VLAN ID 1 having
.B eth0
as its parent interface.
.P
VLAN interfaces are mostly treated as independent interfaces.
As such, a VLAN interface is normally not automatically brought up when its parent interface is brought up.
The exception is when ifup is called with the --allow option,
in which case all VLAN interfaces that are in the same allow class as the parent interface
are brought up together with the parent interface.
For example:
.P
.EX
allow-hotplug eth0 eth0.1

iface eth0 inet static
     address ...

iface eth0.1 inet static
     address ...

iface eth0.2 inet static
     address ...
.EE
.P
In the above example,
when "ifup --allow hotplug eth0" is called (either manually or because udev triggers this when a network device is hotplugged),
the interface eth0 and the VLAN interface eth0.1 are brought up, but eth0.2 is not.
.P
Keep in mind that pattern matching will only match interfaces the kernel knows about,
so it is not possible to specify "auto /eth0.*" and have all VLAN interfaces for eth0 be brought up at boot time.
Another way to ensure that a VLAN interface is brought up automatically when the parent interface is brought up,
is to use a recursive call to ifup, like so:
.P
.EX
iface eth0 inet manual
     up ifup eth0.3

iface eth0.3 inet static
     address ...
.EE
.P
Note that there is no need to add an explicit call to ifdown,
since VLAN interfaces are automatically brought down whenever their parent interfaces are brought down.
.SH IFACE OPTIONS
The following "command" options are available for every family and method.
Each of these options can be given multiple times in a single stanza,
in which case the commands are executed in the order in which they appear
in the stanza.
(You can ensure a command never fails by suffixing them with "|| true".)
.TP
.BI pre\-up " command"
Run
.I command
before bringing the interface up.
If this command fails then
.B ifup
aborts,
refraining from marking the interface as configured,
prints an error message,
and exits with status 0.
This behavior may change in the future.
.TP
\fBup\fR \fIcommand\fR, \fBpost\-up\fR \fIcommand
Run
.I command
after bringing the interface up.
If this command fails then
.B ifup
aborts,
refraining from marking the interface as configured
(even though it has really been configured),
prints an error message,
and exits with status 0.
This behavior may change in the future.
.TP
\fBdown\fR \fIcommand\fR, \fBpre\-down\fR \fIcommand\fR
Run
.I command
before taking the interface down.
If this command fails then
.B ifdown
aborts,
marks the interface as deconfigured
(even though it has not really been deconfigured),
and exits with status 0.
This behavior may change in the future.
.TP
.BI post\-down " command"
Run
.I command
after taking the interface down.
If this command fails then
.B ifdown
aborts,
marks the interface as deconfigured,
and exits with status 0.
This behavior may change in the future.
.TP
.BI description " name"
Alias interface by
.I name
.SH HOOK SCRIPTS
There are four directories in which scripts can be placed which will always be run
for any interface during certain phases of ifup and ifdown commands. These are:
.TP
.IR /etc/network/if-pre-up.d/
Scripts in this directory are run before bringing the interface up.
.TP
.IR /etc/network/if-up.d/
Scripts in this directory are run after bringing the interface up.
.TP
.IR /etc/network/if-down.d/
Scripts in this directory are run before bringing the interface down.
.TP
.IR /etc/network/if-post-down.d/
Scripts in this directory are run after bringing the interface down.
.P
The scripts in which are run (with no arguments) using
.BR run\-parts (8)
after the corresponding
.BI pre-up\fR,
.BI up\fR,
.BI down
and
.BI post-down
options in the
.IR /etc/network/interfaces
file itself have been processed. Please note that as
.BI post\-up
and
.BI pre\-down
are aliases, no files in the corresponding directories are processed.
Please use
.IR if-up.d
and
.IR if-down.d
directories instead.
.SH ENVIRONMENT VARIABLES
All hook scripts, and the commands executed by
.BI pre-up\fR,
.BI up\fR,
.BI post-up\fR,
.BI pre-down\fR,
.BI down
and
.BI post-down
have access to the following environment variables:
.TP
.B IFACE
The physical name of the interface being processed, or "--all" (see below).
.TP
.B LOGICAL
The logical name of the interface being processed, or "auto" (see below).
.TP
.B ADDRFAM
The address family of the interface, or "meta" (see below).
.TP
.B METHOD
The method of the interface (e.g.,
.IR static ),
or "none" (see below).
.TP
.B CLASS
The class of interfaces being processed.
This is a copy of the value given to the \fB-\-allow\fP option when running ifup or ifdown,
otherwise it is set to "auto" when the \fB-\-all\fP option is used.
.TP
.B MODE
.IR start " if run from ifup, " stop " if run from ifdown".
.TP
.B PHASE
As per MODE, but with finer granularity, distinguishing the
\fIpre-up\fR, \fIpost-up\fR, \fIpre-down\fR and \fIpost-down\fR phases.
.TP
.B VERBOSITY
Indicates whether \fB\-\-verbose\fR was used; set to 1 if so, 0 if not.
.TP
.B PATH
The command search path:
.I /usr/local/sbin:\%/usr/local/bin:\%/usr/sbin:\%/usr/bin:\%/sbin:\%/bin
.P
Additionally, all options given in an interface definition stanza are
exported to the environment in upper case with "IF_" prepended and with
hyphens converted to underscores and non\-alphanumeric characters discarded.
.P
When ifupdown is being called with the \fB\-\-all\fR option, before doing anything
to interfaces, it calls all the hook scripts (\fIpre-up\fR or \fIdown\fR) with
\fBIFACE\fR set to "\-\-all", \fBLOGICAL\fR set to the current value of \-\-allow
parameter (or "auto" if it's not set), \fBADDRFAM\fR="meta" and \fBMETHOD\fR="none".
After all the interfaces have been brought up or taken down, the appropriate scripts
(\fIup\fR or \fIpost-down\fR) are executed.
.SH CONCURRENCY AND PARALLEL EXECUTION
Ifupdown uses per-interface locking to ensure that concurrent ifup and ifdown calls to the same interface are run in serial.
However, calls to different interfaces will be able to run in parallel.
It is therefore important that any hook scripts and \fIpre-up\fR, \fIup\fR, \fIdown\fR and \fIpost-down\fR commands are written with the possibility of parallel execution in mind.
.P
It is allowed to recursively call
.BI ifup
and
.BI ifdown
from hook scripts and interface commands,
as long as these calls refer to a different interface than the one that is already being (de)configured.
Loops are detected and will result in the call failing instead of a deadlock,
although it is best if one does not rely on that.
.SH OPTIONS PROVIDED BY OTHER PACKAGES
This manual page documents the configuration options provided by the ifupdown package.
However, other packages can make other options available for use in /etc/network/interfaces.
Here is a list of packages that provide such extensions:
.P
arping, avahi-autoipd, avahi-daemon, bind9, bridge-utils, clamav-freshclam, controlaula, epoptes-client, ethtool, guidedog, hostap-utils, hostapd, htpdate, ifenslave, ifmetric, ifupdown-extra, ifupdown-multi, ifupdown-scripts-zg2, initscripts, isatapd, linux-wlan-ng, lprng, macchanger, miredo, nslcd, ntpdate, openntpd, openresolv, openssh-server, openvpn, openvswitch-switch, postfix, resolvconf, sendmail-base, shorewall-init, slrn, slrnpull, tinc, ucarp, uml-utilities, uruk, vde2, vlan, vzctl, whereami, wide-dhcpv6-client, wireless-tools, wpasupplicant.
.P
Please consult the documentation of those packages for information about how they extend ifupdown.
##ADDRESSFAM##
.SH KNOWN BUGS/LIMITATIONS
The
.B ifup
and
.B ifdown
programs work with so-called "physical" interface names.
These names are assigned to hardware by the kernel.
Unfortunately it can happen that the kernel assigns different
physical interface names to the same hardware at different
times; for example, what was called "eth0" last time you booted
is now called "eth1" and vice versa.
This creates a problem if you want to configure the interfaces
appropriately.
A way to deal with this problem is to use mapping scripts that
choose logical interface names according to the properties of
the interface hardware.
See the
.B get-mac-address.sh
script in the examples directory for an example of such a mapping
script.  See also Debian bug #101728.
.SH AUTHOR
The ifupdown suite was written by Anthony Towns <aj@azure.humbug.org.au>.
This manpage was contributed by Joey Hess <joey@kitenet.net>.
.SH "SEE ALSO"
.BR ifup (8),
.BR ip (8),
.BR ifconfig (8),
.BR run\-parts (8),
.BR resolvconf (8).
.P
For advice on configuring this package read the
.B Network Configuration
chapter of the \fIDebian Reference\fR manual,
available at
\fIhttp://www.debian.org/doc/manuals/debian-reference/ch05.en.html\fR
or in the \fBdebian-reference-en\fR package.
.P
Examples of how to set up interfaces can be found in
.BR /usr/share/doc/ifupdown/examples/network-interfaces.gz .