1.\" $OpenBSD: hostname.if.5,v 1.67 2019/08/30 20:20:51 jmc 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: August 30 2019 $ 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 resolver library routines. 146.Pp 147If no address is specified, the 148.Va netmask , 149.Va broadcast_addr , 150.Li dest , 151and 152.Va dest_addr 153options are invalid and will be ignored. 154.It Va netmask 155The optional network mask for the interface, e.g., 156255.255.255.0. 157If 158.Va addr 159is specified but 160.Va netmask 161is not, the classful mask based on 162.Va addr 163is used. 164.It Va broadcast_addr 165The optional broadcast address for the interface, e.g., 166190.191.192.255. 167The word 168.Dq NONE 169can also be specified in order to configure the broadcast address based 170on the 171.Va netmask . 172The 173.Va netmask 174option must be present in order to use this option. 175.It Va options 176Miscellaneous options to set on the interface, e.g., 177.Dq media 100baseTX mediaopt full-duplex . 178Valid options for a particular interface type can be found in 179.Xr ifconfig 8 . 180When used, the 181.Va netmask 182and 183.Va broadcast_addr 184options must also be present. 185.It Li dest 186If the interface needs a destination address set, this is the literal text 187.Dq dest . 188As shown in the example, this declaration should start on a separate line. 189.It Va dest_addr 190The destination address to be set on the interface, such as 191190.191.192.2. 192It is also feasible to use a hostname as specified in 193.Pa /etc/hosts . 194It is recommended that an address be used instead of symbolic information 195which might activate resolver library routines. 196.It Va prefixlen 197The prefixlen number, or number of bits in the netmask, to be set on 198the interface, such as 64. 199.It Li # 200Comments are allowed. 201Anything following a comment character is treated as a comment. 202.It Li \&! Ns Ar command 203Arbitrary shell commands can be executed using this directive, as 204long as they are available in the single-user environment (for 205instance, 206.Pa /bin 207or 208.Pa /sbin ) . 209Useful for doing interface-specific configuration such as 210setting up custom routes using 211.Xr route 8 212or establishing tunnels using 213.Xr ifconfig 8 . 214It is worth noting that 215.Dq \e$if 216in a command line will be replaced by the interface name. 217.El 218.Sh DYNAMIC ADDRESS CONFIGURATION 219The following packed formats are valid for configuring network 220interfaces with dynamic addresses: 221.Pp 222A DHCP-configured network interface setup consists of 223.Bd -ragged -offset indent 224.Li dhcp 225.Va options 226.Ed 227.Pp 228The above format has the following field values: 229.Bl -tag -width "optionsXXX" -offset indent 230.It Li dhcp 231The literal string 232.Dq dhcp 233if the interface is to be configured using DHCP. 234See 235.Xr dhclient 8 236and 237.Xr dhclient.conf 5 238for more details. 239.It Va options 240Miscellaneous options to set on the interface, e.g., 241.Dq media 100baseTX mediaopt full-duplex . 242Valid options for a particular interface type can be found in 243.Xr ifconfig 8 . 244.El 245.Pp 246IPv6 stateless address autoconfiguration: 247.Bd -ragged -offset indent 248.Li inet6 autoconf 249.Va options 250.Ed 251.Pp 252The above format has the following field values: 253.Bl -tag -width "optionsXXX" -offset indent 254.It Li inet6 255The address family. 256.It Li autoconf 257The literal string 258.Dq autoconf , 259to configure the interface 260using IPv6 stateless address autoconfiguration (SLAAC). 261.It Va options 262Miscellaneous options to set on the interface, e.g., 263.Dq media 100baseTX mediaopt full-duplex . 264Valid options for a particular interface type can be found in 265.Xr ifconfig 8 . 266.El 267.Sh BRIDGE INTERFACE CONFIGURATION 268If the network interface is a bridge, the options described in 269the bridge section of the 270.Xr ifconfig 8 271manual page apply. 272.Pp 273For example: 274.Bd -literal -offset indent 275add fxp0 276add ep1 277-learn fxp0 278# 279!ipsecctl -F 280# 281static fxp0 8:0:20:1e:2f:2b 282up # and finally enable it 283.Ed 284.Sh FILES 285.Bl -tag -width "/etc/hostname.XXXXXX" 286.It Pa /etc/hostname.XXX 287Interface-specific configuration files. 288.El 289.Sh SEE ALSO 290.Xr hosts 5 , 291.Xr dhclient 8 , 292.Xr ifconfig 8 , 293.Xr netstart 8 , 294.Xr rc 8 295