xref: /netbsd-src/share/man/man5/ifconfig.if.5 (revision 404fbe5fb94ca1e054339640cabb2801ce52dd30)
1.\"	$NetBSD: ifconfig.if.5,v 1.13 2009/01/09 09:39:05 apb 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 January 9, 2009
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).
59The variable or file will get evaluated only if the interface exists on
60the system.
61Multiple lines can be placed in a variable or file, and will be
62evaluated sequentially.
63In the case of a variable, semicolons may be used instead of
64newlines, as described in
65.Xr rc.conf 5 .
66.Pp
67Normally, a line will be evaluated as command line arguments to
68.Xr ifconfig 8 .
69.Dq Li ifconfig Ar nnX
70will be prepended on evaluation.
71Arguments with embedded shell metacharacters should be quoted in
72.Xr sh 1
73style.
74.Pp
75If the line is equal to
76.Dq dhcp ,
77.Xr dhcpcd 8
78will be started for the interface.
79.Pp
80If a line is empty, or starts with
81.Sq # ,
82the line will be ignored as comment.
83.Pp
84If a line starts with
85.Sq \&! ,
86the rest of line will get evaluated as shell script fragment.
87Shell variables declared in
88.Pa /etc/rc.d/network
89are accessible but may not be modified.
90The most useful variable is
91.Li $int ,
92as it will be bound to the interface being configured with the file.
93.Pp
94For example, the following illustrates static interface configuration:
95.Bd -literal -offset indent
96# IPv4, with an alias
97inet 10.0.1.12 netmask 255.255.255.0 media 100baseTX
98inet 10.0.1.13 netmask 255.255.255.255 alias
99# let us have IPv6 address on this interface
100inet6 2001:db8::1 prefixlen 64 alias
101# have subnet router anycast address too
102inet6 2001:db8:: prefixlen 64 alias anycast
103.Ed
104.Pp
105The following illustrates dynamic configuration setup with
106.Xr dhclient 8
107and
108.Xr rtsol 8 :
109.Bd -literal -offset indent
110up
111# autoconfigure IPv4 address
112!dhclient $int
113# autoconfigure IPv6 address.  Be sure to set $ip6mode to autohost.
114!rtsol $int
115.Ed
116.Pp
117The following example sets a network name for a wireless interface
118(using quotes to protect special characters in the name),
119and starts
120.Xr dhcpcd 8 :
121.Bd -literal -offset indent
122ssid 'my network'
123dhcp
124.Ed
125.Pp
126The following example is for dynamically-created pseudo interfaces like
127.Xr gif 4 .
128Earlier versions of
129.Pa /etc/rc.d/network
130required an explicit
131.Sq create
132command for such interfaces,
133but creation is now handled automatically.
134.Bd -literal -offset indent
135up
136# configure IPv6 default route toward the interface
137!route add -inet6 default ::1
138!route change -inet6 default -ifp $int
139.Ed
140.Sh FILES
141.Pa /etc/rc.d/network
142.Sh SEE ALSO
143.Xr rc.conf 5 ,
144.Xr ifconfig 8
145