xref: /netbsd-src/share/man/man5/ifconfig.if.5 (revision 9de06003f889cb19b042f7f22b7fe8383ab53a85)
1.\"	$NetBSD: ifconfig.if.5,v 1.22 2020/10/11 22:46:24 kim Exp $
2.\"
3.\" Copyright (c) 1996 Matthew R. Green
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25.\" SUCH DAMAGE.
26.\"
27.Dd October 12, 2020
28.Dt IFCONFIG.IF 5
29.Os
30.Sh NAME
31.Nm ifconfig.if
32.Nd interface-specific configuration files or variables
33.Sh DESCRIPTION
34The
35.Nm
36files or variables contain information regarding the configuration
37of each network interface.
38.Nm
39is processed by
40.Pa /etc/rc.d/network
41at system boot time.
42.Pp
43For each interface
44.Pq Ar nnX
45that is to be configured, there should be either an
46.Sy ifconfig_nnX
47variable in
48.Xr rc.conf 5 ,
49or an
50.Pa /etc/ifconfig.nnX
51file
52(such as the
53.Sy ifconfig_fxp0
54variable or the
55.Pa /etc/ifconfig.fxp0
56file for the
57.Sy fxp0
58interface).
59Only characters allowed in
60.Xr sh 1
61variables names should be used for
62.Ar nnX
63.Po Xr ascii 7
64uppercase and lowercase letters, digits, and underscore
65.Pc .
66.Pp
67The variable or file will get evaluated only if the interface exists on
68the system.
69Multiple lines can be placed in a variable or file, and will be
70evaluated sequentially.
71In the case of a variable, semicolons may be used instead of
72newlines, as described in
73.Xr rc.conf 5 .
74.Ao backslash Ac Ns Ao newline Ac
75sequences in files are ignored, so long logical lines may be
76made up of several shorter physical lines.
77.Pp
78Normally, a line will be evaluated as command line arguments to
79.Xr ifconfig 8 .
80.Dq Li ifconfig Ar nnX
81will be prepended on evaluation.
82Arguments with embedded shell metacharacters should be quoted in
83.Xr sh 1
84style.
85.Pp
86If the line is equal to
87.Dq dhcp ,
88.Xr dhcpcd 8
89will be started for the interface.
90However, it is instead recommended that
91.Sy dhcpcd
92is set to true in
93.Xr rc.conf 5
94and any per interface configuration or restriction is done in
95.Xr dhcpcd.conf 5 .
96.Pp
97If the line is equal to
98.Dq rtsol ,
99a dedicated
100.Xr dhcpcd 8
101process will be started for processing received router advertisements
102and sending out IPv6 router solicitation messages on the interface.
103This is useful on networks where default routes can best be learned
104from router advertisements.
105However, if
106.Sy dhcpcd
107has been set to true in
108.Xr rc.conf 5 ,
109it is assumed that that
110.Xr dhcpcd 8
111process will take care of sending any necessary router solicitation
112messages and processing received router advertisements on all
113interfaces, and therefore no per-interface process is started.
114.Pp
115If a line is empty, or starts with
116.Sq # ,
117the line will be ignored as comment.
118.Pp
119If a line starts with
120.Sq \&! ,
121the rest of line will get evaluated as shell script fragment.
122Shell variables declared in
123.Pa /etc/rc.d/network
124are accessible but may not be modified.
125The most useful variable is
126.Li $int ,
127as it will be bound to the interface being configured with the file.
128.Pp
129For example, the following illustrates static interface configuration:
130.Bd -literal -offset indent
131# IPv4, with an alias
132inet 10.0.1.12 netmask 255.255.255.0 media 100baseTX
133inet 10.0.1.13 netmask 255.255.255.255 alias
134# let us have IPv6 address on this interface
135inet6 2001:db8::1 prefixlen 64 alias
136# have subnet router anycast address too
137inet6 2001:db8:: prefixlen 64 alias anycast
138.Ed
139.Pp
140For networks that do not use a virtual address for the default gateway
141that could be set using a single address in
142.Sy defaultroute6 ,
143static IPv6 address configuration could use the
144.Dq rtsol
145keyword instead to solicit router advertisements for learning a default
146route and even achieving route redundancy given multiple responding
147routers:
148.Bd -literal -offset indent
149inet6 2001:db8::100 prefixlen 64 alias
150rtsol
151.Ed
152.Pp
153The following example sets a network name for a wireless interface
154(using quotes to protect special characters in the name),
155and starts
156.Xr dhcpcd 8 :
157.Bd -literal -offset indent
158ssid 'my network'
159dhcp
160.Ed
161.Pp
162The following example is for dynamically-created pseudo interfaces like
163.Xr gif 4 .
164Earlier versions of
165.Pa /etc/rc.d/network
166required an explicit
167.Sq create
168command for such interfaces,
169but creation is now handled automatically.
170.Bd -literal -offset indent
171up
172# configure IPv6 default route toward the interface
173!route add -inet6 default ::1
174!route change -inet6 default -ifp $int
175.Ed
176.Sh FILES
177.Pa /etc/rc.d/network
178.Sh SEE ALSO
179.Xr rc.conf 5 ,
180.Xr ifconfig 8
181