1.\" $OpenBSD: hostname.if.5,v 1.77 2021/07/17 15:28:31 kn 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 17 2021 $ 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 72inet autoconf 73.Ed 74.Pp 75would run ifconfig three times to set the 76.Cm nwid 77and 78.Cm wpakey 79of the interface, 80the 81.Sy AUTOCONF6 82flag and the 83.Sy AUTOCONF4 84flag, respectively. 85.Sh STATIC ADDRESS CONFIGURATION 86The following packed formats are valid for configuring network 87interfaces with static addresses. 88.Pp 89Regular IPv4 network setup: 90.Bd -ragged -offset indent 91.Li inet 92.Op Li alias 93.Va addr 94.Va netmask 95.Va broadcast_addr 96.Va options 97.br 98.Li dest 99.Va dest_addr 100.Ed 101.Pp 102Regular IPv6 network setup: 103.Bd -ragged -offset indent 104.Li inet6 105.Op Li alias 106.Va addr 107.Va prefixlen 108.Va options 109.br 110.Li dest 111.Va dest_addr 112.Ed 113.Pp 114Other network setup: 115.Bd -ragged -offset indent 116.Va addr_family 117.Va options 118.Ed 119.Pp 120A typical file contains only one line, but more extensive files are possible, 121for example: 122.Bd -literal -offset 1n 123media 100baseTX description Uplink 124inet 10.0.1.12 255.255.255.0 10.0.1.255 125inet alias 10.0.1.13 255.255.255.255 10.0.1.13 126inet alias 10.0.1.14 255.255.255.255 NONE 127inet alias 10.0.1.15 255.255.255.255 128inet alias 10.0.1.16 0xffffffff 129# This is an example comment line. 130inet6 alias fec0::1 64 131inet6 alias fec0::2 64 anycast 132!route add 65.65.65.65 10.0.1.13 133up 134.Ed 135.Pp 136The above formats have the following field values: 137.Bl -tag -width indent -offset indent 138.It Va addr_family 139The address family of the interface, generally 140.Dq inet 141or 142.Dq inet6 . 143.It Li alias 144The literal string 145.Dq alias 146if this is an additional network address for the interface. 147.It Va addr 148The optional address that belongs to the interface, such as 149190.191.192.1 or fe80:2::1. 150It is also feasible to use a hostname as specified in 151.Pa /etc/hosts . 152It is recommended that an address be used instead of symbolic information, 153since the latter might activate resolver library routines. 154.Pp 155If no address is specified, the 156.Va netmask , 157.Va broadcast_addr , 158.Li dest , 159and 160.Va dest_addr 161options are invalid and will be ignored. 162.It Va netmask 163The optional network mask for the interface, e.g., 164255.255.255.0. 165If 166.Va addr 167is specified but 168.Va netmask 169is not, the classful mask based on 170.Va addr 171is used. 172.It Va broadcast_addr 173The optional broadcast address for the interface, e.g., 174190.191.192.255. 175The word 176.Dq NONE 177can also be specified in order to configure the broadcast address based 178on the 179.Va netmask . 180The 181.Va netmask 182option must be present in order to use this option. 183.It Va options 184Miscellaneous options to set on the interface, e.g., 185.Dq media 100baseTX mediaopt full-duplex . 186Valid options for a particular interface type can be found in 187.Xr ifconfig 8 . 188When used, the 189.Va netmask 190and 191.Va broadcast_addr 192options must also be present. 193.It Li dest 194If the interface needs a destination address set, this is the literal text 195.Dq dest . 196As shown in the example, this declaration should start on a separate line. 197.It Va dest_addr 198The destination address to be set on the interface, such as 199190.191.192.2. 200It is also feasible to use a hostname as specified in 201.Pa /etc/hosts . 202It is recommended that an address be used instead of symbolic information 203which might activate resolver library routines. 204.It Va prefixlen 205The prefixlen number, or number of bits in the netmask, to be set on 206the interface, such as 64. 207.It Li # 208Comments are allowed. 209Anything following a comment character is treated as a comment. 210.It Li \&! Ns Ar command 211Arbitrary shell commands can be executed using this directive, as 212long as they are available in the single-user environment (for 213instance, 214.Pa /bin 215or 216.Pa /sbin ) . 217Useful for doing interface-specific configuration such as 218setting up custom routes or default source IP address using 219.Xr route 8 220or establishing tunnels using 221.Xr ifconfig 8 . 222It is worth noting that 223.Dq \e$if 224in a command line will be replaced by the interface name. 225.Pp 226For example, 227to set 192.0.2.1 and 2001:db8::1 as source IP addresses for 228outgoing connections: 229.Bd -literal -offset indent 230inet 192.0.2.1/32 231inet6 2001:db8::1/128 232up 233!route sourceaddr -ifp \e$if 234.Ed 235.El 236.Sh DYNAMIC ADDRESS CONFIGURATION 237IPv4 dynamic addressing via DHCP is requested using 238.Dq inet autoconf 239followed by any options to be passed to 240.Xr ifconfig 8 . 241.Bd -ragged -offset indent 242.Li inet autoconf 243.Op Va ifconfig_options 244.Ed 245.Pp 246The token 247.Dq dhcp 248on its own line without any options is short for 249.Dq inet autoconf . 250.Pp 251IPv6 stateless address autoconfiguration is requested using 252the literal string 253.Dq inet6 autoconf 254followed by any options to be passed to 255.Xr ifconfig 8 . 256.Bd -ragged -offset indent 257.Li inet6 autoconf 258.Op Va ifconfig_options 259.Ed 260.Pp 261The 262.Va autoconf 263configurations will communicate learned DNS information to 264.Xr resolvd 8 . 265.Sh BRIDGE INTERFACE CONFIGURATION 266If the network interface is a bridge, the options described in 267the bridge section of the 268.Xr ifconfig 8 269manual page apply. 270.Pp 271For example: 272.Bd -literal -offset indent 273add fxp0 274add ep1 275-learn fxp0 276# 277!ipsecctl -F 278# 279static fxp0 8:0:20:1e:2f:2b 280up # and finally enable it 281.Ed 282.Sh FILES 283.Bl -tag -width "/etc/hostname.XXXXXX" 284.It Pa /etc/hostname.XXX 285Interface-specific configuration files. 286.El 287.Sh SEE ALSO 288.Xr hosts 5 , 289.Xr ifconfig 8 , 290.Xr netstart 8 , 291.Xr rc 8 , 292.Xr slaacd 8 293