{
    "content": [
        {
            "type": "text",
            "text": "# netdevice (man)\n\n## NAME\n\nnetdevice - low-level access to Linux network devices\n\n## DESCRIPTION\n\nThis man page describes the sockets interface which is used to configure network devices.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS** (2 subsections)\n- **DESCRIPTION** (1 subsections)\n- **NOTES**\n- **BUGS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "netdevice",
        "section": "",
        "mode": "man",
        "summary": "netdevice - low-level access to Linux network devices",
        "synopsis": "",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "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"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "#include <sys/ioctl.h>",
                        "lines": 1
                    },
                    {
                        "name": "#include <net/if.h>",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "DESCRIPTION",
                "lines": 37,
                "subsections": [
                    {
                        "name": "Ioctls",
                        "lines": 171
                    }
                ]
            },
            {
                "name": "NOTES",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            }
        ],
        "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\nAFINET6 is an exception.  It passes an in6ifreq structure:\n\nstruct in6ifreq {\nstruct in6addr     ifr6addr;\nu32                 ifr6prefixlen;\nint                 ifr6ifindex; /* Interface index */\n};\n\nNormally, the user specifies which device to affect by setting ifrname to the  name  of  the\ninterface  or ifr6ifindex to the index of the interface.  All other members of the structure\nmay 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\nSIOCSIFFLAGS\nGet  or  set the active flag word of the device.  ifrflags contains a bit mask of the\nfollowing values:\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.\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\nSIOCSIFPFLAGS\nGet or set extended (private) flags for the device.  ifrflags contains a bit mask  of\nthe following values:\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\nSIOCSIFADDR\nSIOCDIFADDR\nGet,  set,  or  delete  the  address  of  the device using ifraddr, or ifr6addr with\nifr6prefixlen.  Setting or deleting the interface address is a privileged  operation.\nFor  compatibility,  SIOCGIFADDR  returns  only AFINET addresses, SIOCSIFADDR accepts\nAFINET and AFINET6 addresses, and SIOCDIFADDR deletes only  AFINET6  addresses.   A\nAFINET address can be deleted by setting it to zero via SIOCSIFADDR.\n\nSIOCGIFDSTADDR\nSIOCSIFDSTADDR\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\nSIOCSIFBRDADDR\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\nSIOCSIFNETMASK\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\nSIOCSIFMETRIC\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\nSIOCSIFMTU\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\nSIOCSIFHWADDR\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\nSIOCSIFMAP\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\nSIOCDELMULTI\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\nSIOCSIFTXQLEN\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\nAFINET6  IPv6  addresses  can be read from /proc/net/ifinet6 or via rtnetlink(7).  Adding a\nnew IPv6 address and deleting an existing IPv6 address can be done via SIOCSIFADDR and SIOCD‐\nIFADDR or via rtnetlink(7).  Retrieving or changing destination IPv6 addresses of a point-to-\npoint interface is possible only 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\nLinux man-pages 6.7                          2023-10-31                                 netdevice(7)",
                "subsections": []
            }
        }
    }
}