{
    "mode": "man",
    "parameter": "netdevice",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/netdevice/7/json",
    "generated": "2026-05-30T05:09:57Z",
    "synopsis": "",
    "sections": {
        "NAME": {
            "content": "netdevice - low-level access to Linux network devices\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "",
            "subsections": [
                {
                    "name": "#include <sys/ioctl.h>",
                    "content": ""
                },
                {
                    "name": "#include <net/if.h>",
                    "content": ""
                }
            ]
        },
        "DESCRIPTION": {
            "content": "This man page describes the sockets interface which is used to configure network devices.\n\nLinux  supports  some  standard ioctls to configure network devices.  They can be used on any\nsocket's file descriptor regardless of the family or type.  Most of them pass an ifreq struc‐\nture:\n\nstruct ifreq {\nchar ifrname[IFNAMSIZ]; /* Interface name */\nunion {\nstruct sockaddr ifraddr;\nstruct sockaddr ifrdstaddr;\nstruct sockaddr ifrbroadaddr;\nstruct sockaddr ifrnetmask;\nstruct sockaddr ifrhwaddr;\nshort           ifrflags;\nint             ifrifindex;\nint             ifrmetric;\nint             ifrmtu;\nstruct ifmap    ifrmap;\nchar            ifrslave[IFNAMSIZ];\nchar            ifrnewname[IFNAMSIZ];\nchar           *ifrdata;\n};\n};\n\nNormally,  the  user  specifies which device to affect by setting ifrname to the name of the\ninterface.  All other members of the structure may share memory.\n",
            "subsections": [
                {
                    "name": "Ioctls",
                    "content": "If an ioctl is marked as privileged, then using it requires an effective user ID of 0 or  the\nCAPNETADMIN capability.  If this is not the case, EPERM will be returned.\n\nSIOCGIFNAME\nGiven the ifrifindex, return the name of the interface in ifrname.  This is the only\nioctl which returns its result in ifrname.\n\nSIOCGIFINDEX\nRetrieve the interface index of the interface into ifrifindex.\n\nSIOCGIFFLAGS, SIOCSIFFLAGS\nGet or set the active flag word of the device.  ifrflags contains a bit mask  of  the\nfollowing values:\n\nDevice flags\nIFFUP            Interface is running.\nIFFBROADCAST     Valid broadcast address set.\nIFFDEBUG         Internal debugging flag.\nIFFLOOPBACK      Interface is a loopback interface.\nIFFPOINTOPOINT   Interface is a point-to-point link.\nIFFRUNNING       Resources allocated.\nIFFNOARP         No arp protocol, L2 destination address not\nset.\nIFFPROMISC       Interface is in promiscuous mode.\n\nIFFNOTRAILERS    Avoid use of trailers.\nIFFALLMULTI      Receive all multicast packets.\nIFFMASTER        Master of a load balancing bundle.\nIFFSLAVE         Slave of a load balancing bundle.\nIFFMULTICAST     Supports multicast\nIFFPORTSEL       Is able to select media type via ifmap.\nIFFAUTOMEDIA     Auto media selection active.\nIFFDYNAMIC       The addresses are lost when the interface\ngoes down.\nIFFLOWERUP      Driver signals L1 up (since Linux 2.6.17)\nIFFDORMANT       Driver signals dormant (since Linux 2.6.17)\nIFFECHO          Echo sent packets (since Linux 2.6.25)\n\nSetting the active flag word is a privileged operation, but any process may read it.\n\nSIOCGIFPFLAGS, SIOCSIFPFLAGS\nGet  or set extended (private) flags for the device.  ifrflags contains a bit mask of\nthe following values:\n\nPrivate flags\nIFF8021QVLAN      Interface is 802.1Q VLAN device.\nIFFEBRIDGE          Interface is Ethernet bridging device.\nIFFSLAVEINACTIVE   Interface is inactive bonding slave.\nIFFMASTER8023AD    Interface is 802.3ad bonding master.\nIFFMASTERALB       Interface is balanced-alb bonding master.\nIFFBONDING          Interface is a bonding master or slave.\nIFFSLAVENEEDARP    Interface needs ARPs for validation.\nIFFISATAP           Interface is RFC4214 ISATAP interface.\n\nSetting the extended (private) interface flags is a privileged operation.\n\nSIOCGIFADDR, SIOCSIFADDR\nGet or set the address of the device using ifraddr.  Setting the interface address is\na privileged operation.  For compatibility, only AFINET addresses are accepted or re‐\nturned.\n\nSIOCGIFDSTADDR, SIOCSIFDSTADDR\nGet or set the destination address of a point-to-point device using ifrdstaddr.   For\ncompatibility,  only AFINET addresses are accepted or returned.  Setting the destina‐\ntion address is a privileged operation.\n\nSIOCGIFBRDADDR, SIOCSIFBRDADDR\nGet or set the broadcast address for a device using ifrbrdaddr.   For  compatibility,\nonly  AFINET  addresses are accepted or returned.  Setting the broadcast address is a\nprivileged operation.\n\nSIOCGIFNETMASK, SIOCSIFNETMASK\nGet or set the network mask for a device using ifrnetmask.  For  compatibility,  only\nAFINET  addresses are accepted or returned.  Setting the network mask is a privileged\noperation.\n\nSIOCGIFMETRIC, SIOCSIFMETRIC\nGet or set the metric of the device using ifrmetric.  This is  currently  not  imple‐\nmented;  it  sets  ifrmetric to 0 if you attempt to read it and returns EOPNOTSUPP if\nyou attempt to set it.\n\nSIOCGIFMTU, SIOCSIFMTU\nGet or set the MTU (Maximum Transfer Unit) of a device using ifrmtu.  Setting the MTU\nis  a  privileged  operation.   Setting  the  MTU to too small values may cause kernel\ncrashes.\n\nSIOCGIFHWADDR, SIOCSIFHWADDR\nGet or set the hardware address of a device using ifrhwaddr.  The hardware address is\nspecified  in a struct sockaddr.  safamily contains the ARPHRD* device type, sadata\nthe L2 hardware address starting from byte 0.  Setting the hardware address is a priv‐\nileged operation.\n\nSIOCSIFHWBROADCAST\nSet  the hardware broadcast address of a device from ifrhwaddr.  This is a privileged\noperation.\n\nSIOCGIFMAP, SIOCSIFMAP\nGet or set the interface's hardware parameters using ifrmap.  Setting the  parameters\nis a privileged operation.\n\nstruct ifmap {\nunsigned long   memstart;\nunsigned long   memend;\nunsigned short  baseaddr;\nunsigned char   irq;\nunsigned char   dma;\nunsigned char   port;\n};\n\nThe  interpretation of the ifmap structure depends on the device driver and the archi‐\ntecture.\n\nSIOCADDMULTI, SIOCDELMULTI\nAdd an address to or delete an address from the device's link layer multicast  filters\nusing  ifrhwaddr.  These are privileged operations.  See also packet(7) for an alter‐\nnative.\n\nSIOCGIFTXQLEN, SIOCSIFTXQLEN\nGet or set the transmit queue length of a device using ifrqlen.  Setting the transmit\nqueue length is a privileged operation.\n\nSIOCSIFNAME\nChanges  the  name  of  the interface specified in ifrname to ifrnewname.  This is a\nprivileged operation.  It is allowed only when the interface is not up.\n\nSIOCGIFCONF\nReturn a list of interface (network layer) addresses.  This currently means  only  ad‐\ndresses of the AFINET (IPv4) family for compatibility.  Unlike the others, this ioctl\npasses an ifconf structure:\n\nstruct ifconf {\nint                 ifclen; /* size of buffer */\nunion {\nchar           *ifcbuf; /* buffer address */\nstruct ifreq   *ifcreq; /* array of structures */\n};\n};\n\nIf ifcreq is NULL, SIOCGIFCONF returns the necessary buffer size in bytes for receiv‐\ning  all  available addresses in ifclen.  Otherwise, ifcreq contains a pointer to an\narray of ifreq structures to be filled with all  currently  active  L3  interface  ad‐\ndresses.   ifclen  contains the size of the array in bytes.  Within each ifreq struc‐\nture, ifrname will receive the interface name, and ifraddr the address.  The  actual\nnumber of bytes transferred is returned in ifclen.\n\nIf  the size specified by ifclen is insufficient to store all the addresses, the ker‐\nnel will skip the exceeding ones and return success.  There is no reliable way of  de‐\ntecting  this  condition  once it has occurred.  It is therefore recommended to either\ndetermine the necessary buffer size beforehand by calling SIOCGIFCONF with ifcreq set\nto  NULL,  or to retry the call with a bigger buffer whenever ifclen upon return dif‐\nfers by less than sizeof(struct ifreq) from its original value.\n\nIf an error occurs accessing the ifconf or ifreq structures, EFAULT will be returned.\n\nMost protocols support their own ioctls to  configure  protocol-specific  interface  options.\nSee the protocol man pages for a description.  For configuring IP addresses, see ip(7).\n\nIn addition, some devices support private ioctls.  These are not described here.\n"
                }
            ]
        },
        "NOTES": {
            "content": "SIOCGIFCONF  and the other ioctls that accept or return only AFINET socket addresses are IP-\nspecific and perhaps should rather be documented in ip(7).\n\nThe names of interfaces with no addresses or that don't have the IFFRUNNING flag set can  be\nfound via /proc/net/dev.\n\nLocal IPv6 IP addresses can be found via /proc/net or via rtnetlink(7).\n",
            "subsections": []
        },
        "BUGS": {
            "content": "glibc  2.1 is missing the ifrnewname macro in <net/if.h>.  Add the following to your program\nas a workaround:\n\n#ifndef ifrnewname\n#define ifrnewname     ifrifru.ifruslave\n#endif\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "proc(5), capabilities(7), ip(7), rtnetlink(7)\n",
            "subsections": []
        },
        "COLOPHON": {
            "content": "This page is part of release 5.10 of the Linux  man-pages  project.   A  description  of  the\nproject,  information about reporting bugs, and the latest version of this page, can be found\nat https://www.kernel.org/doc/man-pages/.\n\n\n\nLinux                                        2020-08-13                                 NETDEVICE(7)",
            "subsections": []
        }
    },
    "summary": "netdevice - low-level access to Linux network devices",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "proc",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/proc/5/json"
        },
        {
            "name": "capabilities",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/capabilities/7/json"
        },
        {
            "name": "ip",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ip/7/json"
        },
        {
            "name": "rtnetlink",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/rtnetlink/7/json"
        }
    ]
}