xref: /openbsd-src/share/man/man5/hostname.if.5 (revision d1df930ffab53da22f3324c32bed7ac5709915e6)
1.\"	$OpenBSD: hostname.if.5,v 1.66 2018/07/15 10:46:48 phessler Exp $
2.\"	$NetBSD: hosts.5,v 1.4 1994/11/30 19:31:20 jtc Exp $
3.\"
4.\" Copyright (c) 1983, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)hosts.5	8.2 (Berkeley) 12/11/93
32.\"
33.Dd $Mdocdate: July 15 2018 $
34.Dt HOSTNAME.IF 5
35.Os
36.Sh NAME
37.Nm hostname.if
38.Nd interface-specific configuration files
39.Sh DESCRIPTION
40The
41.Nm hostname.*\&
42files contain information regarding the configuration of each network interface.
43One file should exist for each interface that is to be configured, such as
44.Pa hostname.fxp0
45or
46.Pa hostname.bridge0 .
47A configuration file is not needed for lo0.
48.Pp
49The configuration information is expressed in a line-by-line packed format
50which makes the most common cases simpler; those dense formats are described
51below.
52Any lines not matching these packed formats are passed directly to
53.Xr ifconfig 8 .
54The packed formats are converted using a somewhat inflexible parser and
55the administrator should not expect magic \(em if in doubt study
56.Xr ifconfig 8
57and the
58per-driver manual pages to see what arguments are permitted.
59.Pp
60Arguments containing either whitespace or single quote
61characters must be double quoted.
62For example:
63.Bd -literal -offset indent
64inet 10.0.0.1 255.255.255.0 10.0.0.255 description "Bob's uplink"
65.Ed
66.Pp
67Each line is processed separately and in order.
68For example:
69.Bd -literal -offset indent
70nwid mynwid wpakey mywpakey
71inet6 autoconf
72dhcp
73.Ed
74.Pp
75would run ifconfig to set the nwid and wpakey of the interface, run it again to set the AUTOCONF6 flag, and then start
76.Xr dhclient 8 .
77.Sh STATIC ADDRESS CONFIGURATION
78The following packed formats are valid for configuring network
79interfaces with static addresses:
80.Pp
81Regular IPv4 network setup:
82.Bd -ragged -offset indent
83.Li inet
84.Op Li alias
85.Va addr
86.Va netmask
87.Va broadcast_addr
88.Va options
89.br
90.Li dest
91.Va dest_addr
92.Ed
93.Pp
94Regular IPv6 network setup:
95.Bd -ragged -offset indent
96.Li inet6
97.Op Li alias
98.Va addr
99.Va prefixlen
100.Va options
101.br
102.Li dest
103.Va dest_addr
104.Ed
105.Pp
106Other network setup:
107.Bd -ragged -offset indent
108.Va addr_family
109.Va options
110.Ed
111.Pp
112A typical file contains only one line, but more extensive files are possible,
113for example:
114.Bd -literal -offset 1n
115media 100baseTX description Uplink
116inet 10.0.1.12 255.255.255.0 10.0.1.255
117inet alias 10.0.1.13 255.255.255.255 10.0.1.13
118inet alias 10.0.1.14 255.255.255.255 NONE
119inet alias 10.0.1.15 255.255.255.255
120inet alias 10.0.1.16 0xffffffff
121# This is an example comment line.
122inet6 alias fec0::1 64
123inet6 alias fec0::2 64 anycast
124!route add 65.65.65.65 10.0.1.13
125up
126.Ed
127.Pp
128The above formats have the following field values:
129.Bl -tag -width indent -offset indent
130.It Va addr_family
131The address family of the interface, generally
132.Dq inet
133or
134.Dq inet6 .
135.It Li alias
136The literal string
137.Dq alias
138if this is an additional network address for the interface.
139.It Va addr
140The optional address that belongs to the interface, such as
141190.191.192.1 or fe80:2::1.
142It is also feasible to use a hostname as specified in
143.Pa /etc/hosts .
144It is recommended that an address be used instead of symbolic information,
145since the latter might activate
146.Xr resolver 3
147library routines.
148.Pp
149If no address is specified, the
150.Va netmask ,
151.Va broadcast_addr ,
152.Li dest ,
153and
154.Va dest_addr
155options are invalid and will be ignored.
156.It Va netmask
157The optional network mask for the interface, e.g.,
158255.255.255.0.
159If
160.Va addr
161is specified but
162.Va netmask
163is not, the classful mask based on
164.Va addr
165is used.
166.It Va broadcast_addr
167The optional broadcast address for the interface, e.g.,
168190.191.192.255.
169The word
170.Dq NONE
171can also be specified in order to configure the broadcast address based
172on the
173.Va netmask .
174The
175.Va netmask
176option must be present in order to use this option.
177.It Va options
178Miscellaneous options to set on the interface, e.g.,
179.Dq media 100baseTX mediaopt full-duplex .
180Valid options for a particular interface type can be found in
181.Xr ifconfig 8 .
182When used, the
183.Va netmask
184and
185.Va broadcast_addr
186options must also be present.
187.It Li dest
188If the interface needs a destination address set, this is the literal text
189.Dq dest .
190As shown in the example, this declaration should start on a separate line.
191.It Va dest_addr
192The destination address to be set on the interface, such as
193190.191.192.2.
194It is also feasible to use a hostname as specified in
195.Pa /etc/hosts .
196It is recommended that an address be used instead of symbolic information
197which might activate
198.Xr resolver 3
199library routines.
200.It Va prefixlen
201The prefixlen number, or number of bits in the netmask, to be set on
202the interface, such as 64.
203.It Li #
204Comments are allowed.
205Anything following a comment character is treated as a comment.
206.It Li \&! Ns Ar command
207Arbitrary shell commands can be executed using this directive, as
208long as they are available in the single-user environment (for
209instance,
210.Pa /bin
211or
212.Pa /sbin ) .
213Useful for doing interface-specific configuration such as
214setting up custom routes using
215.Xr route 8
216or establishing tunnels using
217.Xr ifconfig 8 .
218It is worth noting that
219.Dq \e$if
220in a command line will be replaced by the interface name.
221.El
222.Sh DYNAMIC ADDRESS CONFIGURATION
223The following packed formats are valid for configuring network
224interfaces with dynamic addresses:
225.Pp
226A DHCP-configured network interface setup consists of
227.Bd -ragged -offset indent
228.Li dhcp
229.Va options
230.Ed
231.Pp
232The above format has the following field values:
233.Bl -tag -width "optionsXXX" -offset indent
234.It Li dhcp
235The literal string
236.Dq dhcp
237if the interface is to be configured using DHCP.
238See
239.Xr dhclient 8
240and
241.Xr dhclient.conf 5
242for more details.
243.It Va options
244Miscellaneous options to set on the interface, e.g.,
245.Dq media 100baseTX mediaopt full-duplex .
246Valid options for a particular interface type can be found in
247.Xr ifconfig 8 .
248.El
249.Pp
250IPv6 stateless address autoconfiguration:
251.Bd -ragged -offset indent
252.Li inet6 autoconf
253.Va options
254.Ed
255.Pp
256The above format has the following field values:
257.Bl -tag -width "optionsXXX" -offset indent
258.It Li inet6
259The address family.
260.It Li autoconf
261The literal string
262.Dq autoconf ,
263to configure the interface
264using IPv6 stateless address autoconfiguration (SLAAC).
265.It Va options
266Miscellaneous options to set on the interface, e.g.,
267.Dq media 100baseTX mediaopt full-duplex .
268Valid options for a particular interface type can be found in
269.Xr ifconfig 8 .
270.El
271.Sh BRIDGE INTERFACE CONFIGURATION
272If the network interface is a bridge, the options described in
273the bridge section of the
274.Xr ifconfig 8
275manual page apply.
276.Pp
277For example:
278.Bd -literal -offset indent
279add fxp0
280add ep1
281-learn fxp0
282#
283!ipsecctl -F
284#
285static fxp0 8:0:20:1e:2f:2b
286up    # and finally enable it
287.Ed
288.Sh FILES
289.Bl -tag -width "/etc/hostname.XXXXXX"
290.It Pa /etc/hostname.XXX
291Interface-specific configuration files.
292.El
293.Sh SEE ALSO
294.Xr hosts 5 ,
295.Xr dhclient 8 ,
296.Xr ifconfig 8 ,
297.Xr netstart 8 ,
298.Xr rc 8
299