1 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
3 .\" %%%LICENSE_START(VERBATIM_ONE_PARA)
4 .\" Permission is granted to distribute possibly modified copies
5 .\" of this page provided the header is included verbatim,
6 .\" and in case of nontrivial modification author and date
7 .\" of the modification is added to the header.
10 .\" $Id: netdevice.7,v 1.10 2000/08/17 10:09:54 ak Exp $
12 .\" Modified, 2004-11-25, mtk, formatting and a few wording fixes
14 .\" Modified, 2011-11-02, <bidulock@openss7.org>, added many basic
15 .\" but missing ioctls, such as SIOCGIFADDR.
17 .TH NETDEVICE 7 2021-03-22 "Linux" "Linux Programmer's Manual"
19 netdevice \- low-level access to Linux network devices
22 .B "#include <sys/ioctl.h>"
23 .B "#include <net/if.h>"
26 This man page describes the sockets interface which is used to configure
29 Linux supports some standard ioctls to configure network devices.
30 They can be used on any socket's file descriptor regardless of the
39 char ifr_name[IFNAMSIZ]; /* Interface name */
41 struct sockaddr ifr_addr;
42 struct sockaddr ifr_dstaddr;
43 struct sockaddr ifr_broadaddr;
44 struct sockaddr ifr_netmask;
45 struct sockaddr ifr_hwaddr;
51 char ifr_slave[IFNAMSIZ];
52 char ifr_newname[IFNAMSIZ];
68 struct in6_addr ifr6_addr;
70 int ifr6_ifindex; /* Interface index */
75 Normally, the user specifies which device to affect by setting
77 to the name of the interface or
79 to the index of the interface.
80 All other members of the structure may
83 If an ioctl is marked as privileged, then using it requires an effective
87 If this is not the case,
94 return the name of the interface in
96 This is the only ioctl which returns its result in
100 Retrieve the interface index of the interface into
103 .BR SIOCGIFFLAGS ", " SIOCSIFFLAGS
104 Get or set the active flag word of the device.
106 contains a bit mask of the following values:
107 .\" Do not right adjust text blocks in tables
114 IFF_UP:Interface is running.
115 IFF_BROADCAST:Valid broadcast address set.
116 IFF_DEBUG:Internal debugging flag.
117 IFF_LOOPBACK:Interface is a loopback interface.
118 IFF_POINTOPOINT:Interface is a point-to-point link.
119 IFF_RUNNING:Resources allocated.
121 No arp protocol, L2 destination address not set.
123 IFF_PROMISC:Interface is in promiscuous mode.
124 IFF_NOTRAILERS:Avoid use of trailers.
125 IFF_ALLMULTI:Receive all multicast packets.
126 IFF_MASTER:Master of a load balancing bundle.
127 IFF_SLAVE:Slave of a load balancing bundle.
128 IFF_MULTICAST:Supports multicast
129 IFF_PORTSEL:Is able to select media type via ifmap.
130 IFF_AUTOMEDIA:Auto media selection active.
132 The addresses are lost when the interface goes down.
134 IFF_LOWER_UP:Driver signals L1 up (since Linux 2.6.17)
135 IFF_DORMANT:Driver signals dormant (since Linux 2.6.17)
136 IFF_ECHO:Echo sent packets (since Linux 2.6.25)
140 Setting the active flag word is a privileged operation, but any
143 .BR SIOCGIFPFLAGS ", " SIOCSIFPFLAGS
144 Get or set extended (private) flags for the device.
146 contains a bit mask of the following values:
152 IFF_802_1Q_VLAN:Interface is 802.1Q VLAN device.
153 IFF_EBRIDGE:Interface is Ethernet bridging device.
154 IFF_SLAVE_INACTIVE:Interface is inactive bonding slave.
155 IFF_MASTER_8023AD:Interface is 802.3ad bonding master.
156 IFF_MASTER_ALB:Interface is balanced-alb bonding master.
157 IFF_BONDING:Interface is a bonding master or slave.
158 IFF_SLAVE_NEEDARP:Interface needs ARPs for validation.
159 IFF_ISATAP:Interface is RFC4214 ISATAP interface.
162 Setting the extended (private) interface flags is a privileged operation.
164 .BR SIOCGIFADDR ", " SIOCSIFADDR ", " SIOCDIFADDR
165 Get, set, or delete the address of the device using
171 Setting or deleting the interface address is a privileged operation.
189 address can be deleted by setting it to zero via
192 .BR SIOCGIFDSTADDR ", " SIOCSIFDSTADDR
193 Get or set the destination address of a point-to-point device using
195 For compatibility, only
197 addresses are accepted or returned.
198 Setting the destination address is a privileged operation.
200 .BR SIOCGIFBRDADDR ", " SIOCSIFBRDADDR
201 Get or set the broadcast address for a device using
203 For compatibility, only
205 addresses are accepted or returned.
206 Setting the broadcast address is a privileged operation.
208 .BR SIOCGIFNETMASK ", " SIOCSIFNETMASK
209 Get or set the network mask for a device using
211 For compatibility, only
213 addresses are accepted or returned.
214 Setting the network mask is a privileged operation.
216 .BR SIOCGIFMETRIC ", " SIOCSIFMETRIC
217 Get or set the metric of the device using
219 This is currently not implemented; it sets
221 to 0 if you attempt to read it and returns
223 if you attempt to set it.
225 .BR SIOCGIFMTU ", " SIOCSIFMTU
226 Get or set the MTU (Maximum Transfer Unit) of a device using
228 Setting the MTU is a privileged operation.
230 too small values may cause kernel crashes.
232 .BR SIOCGIFHWADDR ", " SIOCSIFHWADDR
233 Get or set the hardware address of a device using
235 The hardware address is specified in a struct
238 contains the ARPHRD_* device type,
240 the L2 hardware address starting from byte 0.
241 Setting the hardware address is a privileged operation.
243 .B SIOCSIFHWBROADCAST
244 Set the hardware broadcast address of a device from
246 This is a privileged operation.
248 .BR SIOCGIFMAP ", " SIOCSIFMAP
249 Get or set the interface's hardware parameters using
251 Setting the parameters is a privileged operation.
256 unsigned long mem_start;
257 unsigned long mem_end;
258 unsigned short base_addr;
266 The interpretation of the ifmap structure depends on the device driver
267 and the architecture.
269 .BR SIOCADDMULTI ", " SIOCDELMULTI
270 Add an address to or delete an address from the device's link layer
271 multicast filters using
273 These are privileged operations.
278 .BR SIOCGIFTXQLEN ", " SIOCSIFTXQLEN
279 Get or set the transmit queue length of a device using
281 Setting the transmit queue length is a privileged operation.
284 Changes the name of the interface specified in
288 This is a privileged operation.
289 It is allowed only when the interface
293 Return a list of interface (network layer) addresses.
295 means only addresses of the
297 (IPv4) family for compatibility.
298 Unlike the others, this ioctl passes an
305 int ifc_len; /* size of buffer */
307 char *ifc_buf; /* buffer address */
308 struct ifreq *ifc_req; /* array of structures */
318 returns the necessary buffer size in bytes
319 for receiving all available addresses in
323 contains a pointer to an array of
325 structures to be filled with all currently active L3 interface addresses.
327 contains the size of the array in bytes.
332 will receive the interface name, and
335 The actual number of bytes transferred is returned in
338 If the size specified by
340 is insufficient to store all the addresses,
341 the kernel will skip the exceeding ones and return success.
342 There is no reliable way of detecting this condition once it has occurred.
343 It is therefore recommended to either determine the necessary buffer size
344 beforehand by calling
348 set to NULL, or to retry the call with a bigger buffer whenever
350 upon return differs by less than
351 .I sizeof(struct ifreq)
352 from its original value.
354 If an error occurs accessing the
361 .\" Slaving isn't supported in 2.2
364 .\" .BR SIOCGIFSLAVE ", " SIOCSIFSLAVE
365 .\" Get or set the slave device using
367 .\" Setting the slave device is a privileged operation.
369 .\" FIXME . add amateur radio stuff.
371 Most protocols support their own ioctls to configure protocol-specific
373 See the protocol man pages for a description.
374 For configuring IP addresses, see
377 In addition, some devices support private ioctls.
378 These are not described here.
381 and the other ioctls that accept or return only
384 are IP-specific and perhaps should rather be documented in
387 The names of interfaces with no addresses or that don't have the
389 flag set can be found via
393 IPv6 addresses can be read from
394 .I /proc/net/if_inet6
397 Adding a new IPv6 address and deleting an existing IPv6 address
404 Retrieving or changing destination IPv6 addresses of a point-to-point
405 interface is possible only via
408 glibc 2.1 is missing the
412 Add the following to your program as a workaround:
417 #define ifr_newname ifr_ifru.ifru_slave
423 .BR capabilities (7),