INET(4)
π INET(4) β Internet protocol family π
okay bestie, this is inet(4) from the Kernel Interfaces Manual, and it's literally the blueprint for how the whole Internet protocol family fits together. buckle up π
β¨ NAME β¨
inet β the Internet protocol family, periodt π
π SYNOPSIS π
#include <sys/types.h>
#include <netinet/in.h>
yes, both of them, in that order, don't @ me π
π¦ DESCRIPTION π¦
So the Internet protocol family is basically a whole squad of protocols stacked on top of the Internet Protocol (IP) transport layer, and they all speak in Internet address format π. That's the vibe.
The Internet family has protocol support for these socket types:
SOCK_STREAMSOCK_DGRAMSOCK_RAW
and the SOCK_RAW interface is the main character that gives you direct access to the IP protocol π₯. iykyk.
π ADDRESSING π
Internet addresses are four byte quantities, stored in network standard format β and on little endian machines (like the alpha, amd64 and i386) those are word and byte reversed π. The include file <netinet/in.h> defines this address as a discriminated union β¨.
Sockets bound to the Internet protocol family use this addressing structure, exactly this one:
struct sockaddr_in {
uint8_t sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
Sockets may be created with the local address INADDR_ANY to affect "wildcard" matching on incoming messages π―. And the address in a connect(2) or sendto(2) call may be given as INADDR_ANY to mean "this host" π«Ά.
Also, the distinguished address INADDR_BROADCAST is allowed as a shorthand for the broadcast address on the primary network β but only if the first network configured supports broadcast π‘. so like, conditional slay. π
π¦ PROTOCOLS π¦
okay so the Internet protocol family is literally a whole friend group π and it's made up of the IP network protocol, the Internet Control Message Protocol (ICMP), the Internet Group Management Protocol (IGMP), the Transmission Control Protocol (TCP), and the User Datagram Protocol (UDP). And like, they each have their role, no cap:
TCPis the one holding up theSOCK_STREAMabstraction π«ΆUDPis the one holding up theSOCK_DGRAMabstraction π- and if you want a raw interface to IP? bestie you can just create an Internet socket of type
SOCK_RAWβ¨
Also the ICMP message protocol is accessible from a raw socket. iykyk.
The inet address on an interface consists of the address itself, the netmask, and then either the broadcast address in the case of a broadcast interface or the peers address in the case of a point-to-point interface. Like, it's giving "full package deal" π
The following ioctl(2) commands are provided for a datagram socket in the Internet domain:
SIOCAIFADDRβ adds an address to an interface. The command requiresstruct in_aliasreqas its argument.SIOCDIFADDRβ deletes an address from an interface. The command requiresstruct ifreqas its argument.SIOCGIFADDRSIOCGIFBRDADDRSIOCGIFDSTADDRSIOCGIFNETMASKβ these four return address information from an interface. The returned value is instruct ifreq. ngl this way of retrieving address info is obsoleted, and the preferred way is to use thegetifaddrs(3)API πΈ
πΈ MIB (sysctl) Variables πΈ
On top of the variables supported by the transport protocols in net.inet (for which you should go read the respective manual pages, bestie, I'm not doing everything for you π«Ά), there are a number of general variables implemented in the net.inet.ip branch of the sysctl(3) MIB, which can also be read or modified with sysctl(8). The following general variables are defined:
accept_sourcerouteβ Boolean: enables/disables accepting of source-routed IP packets (defaultfalse).allow_net0β Boolean: allows forwarding of, and ICMP responses to, packets with addresses in0.0.0.0/8.allow_net240β Boolean: allows forwarding of, and ICMP responses to, packets with addresses in240.0.0.0/4.curfragsβ Integer: the current number of IPv4 fragments across all reassembly queues in all VNETs (read-only).forwardingβ Boolean: enables/disables forwarding of IP packets. Defaults to off.fragpacketsβ Integer: the current number of IPv4 fragment reassembly queue entries for the VNET (read-only).fragttlβ Integer: time to live for IPv4 packet fragments in the per-VNET reassembly queue.loopback_prefixlenβ Integer: prefix length of the address space reserved for loopback purposes. The default is8, meaning that127.0.0.0/8is reserved for loopback, and cannot be sent, received, or forwarded on a non-loopback interface. Heads up: use of other values is experimental πmaxfragbucketsizeβ Integer: maximum number of reassembly queues per bucket. Fragmented packets are hashed to buckets. Each bucket has a list of reassembly queues. The system must compare the incoming packets to the existing reassembly queues in the bucket to find a matching reassembly queue. To preserve system resources, the system limits the number of reassembly queues allowed in each bucket. This limit is recalculated when the number of mbuf clusters is changed or when the value ofmaxfragpacketschanges. This is a per-VNET limit.maxfragpacketsβ Integer: maximum number of fragmented packets the host will accept and simultaneously hold in the reassembly queue for a particular VNET.0means that the host will not accept any fragmented packets for that VNET.-1means that the host will not apply this limit for that VNET. This limit is recalculated when the number of mbuf clusters is changed. This is a per-VNET limit.maxfragsβ Integer: maximum number of fragments the host will accept and simultaneously hold across all reassembly queues in all VNETs. If set to0, reassembly is disabled. If set to-1, this limit is not applied. This limit is recalculated when the number of mbuf clusters is changed. This is a global limit.maxfragsperpacketβ Integer: maximum number of fragments the host will accept and hold in the reassembly queue for a packet.0means that the host will not accept any fragmented packets for the VNET. This is a per-VNET limit.mcastβ the variables under thenet.inet.ip.mcastnode are documented inip(4). go look πno_same_prefixβ Boolean: refuses to create same prefixes on different interfaces. This is a per-VNET value.portrangeβ the variables under thenet.inet.ip.portrangenode control port ranges used by transport protocols; seeip(4)for details.process_optionsβ Integer: controls IP options processing. Setting this variable to0makes all IP options in the incoming packets get ignored, and the packets get passed unmodified. Setting it to1means IP options in the incoming packets will be processed accordingly. Setting it to2means an ICMP "prohibited by filter" message will be sent back in response to incoming packets with IP options. Default is1. Thissysctl(8)variable affects packets destined for a local host as well as packets forwarded to some other host π₯random_idβ Boolean: controls IP IDs generation behavior. Setting thissysctl(8)to1causes the ID field in non-atomic IP datagrams (or all IP datagrams, ifrfc6864is disabled) to be randomized instead of incremented by 1 with each packet generated. This closes a minor information leak which allows remote observers to determine the rate of packet generation on the machine by watching the counter. At the same time, on high-speed links, it can decrease the ID reuse cycle greatly. Default is0(sequential IP IDs). Also fyi: IPv6 flow IDs and fragment IDs are always random β¨random_id_collisionsβ Integer: count of IP ID collisions (read-only, per-VNET).random_id_periodβ Integer: size of the IP ID array, which is the number of previous packets for which the IDs are recorded. The number must be between512and32768inclusive. This is a per-VNET value.random_id_totalβ Integer: count of IP IDs created (read-only, per-VNET).reass_hashsizeβ number of hash slots in the IPv4 reassembly queue (loader tunable).redirectβ Boolean: enables/disables sending of ICMP redirects in response to IP packets for which a better, and for the sender directly reachable, route and next hop is known. Defaults to on.rfc1122_strong_esβ Boolean: in non-forwarding mode (i.e. forwarding is disabled), partially implements the Strong End System model per RFC1122. If a packet with a destination address that is local arrives on a different interface than the interface the address belongs to, the packet would be silently dropped. π Enabling this option may break certain setups, e.g. having an alias address(es) on loopback that are expected to be reachable by outside traffic. Enabling some other network features, e.g.carp(4)or destination address rewritingpfil(4)filters, may override and bypass this check. Disabled by default.rfc6864β Boolean: controls IP IDs generation behaviour. A true value enables RFC6864 support, which specifies that the IP ID field of atomic datagrams can be set to any value. The FreeBSD implementation sets it to zero. Enabled by default.source_address_validationβ Boolean: performs source address validation for packets destined for the local host. Think of this as following Section 3.2 of RFC3704/BCP84, where we treat the local host as our own infrastructure. Forwarded packets are unaffected by this, and it should not be considered an anti-spoof feature for a router. Enabled by default.sourcerouteβ Boolean: enables/disables forwarding of source-routed IP packets (defaultfalse).ttlβ Integer: default time-to-live ("TTL") to use for outgoing IP packets π
β¨ SEE ALSO β¨
ioctl(2), socket(2), getifaddrs(3), sysctl(3), icmp(4), intro(4), ip(4), ipfirewall(4), route(4), tcp(4), udp(4), sysctl(8), pfil(9)
And the reading list, because she's well-read obviously π:
- "An Introductory 4.3 BSD Interprocess Communication Tutorial", PS1, 7.
- "An Advanced 4.3 BSD Interprocess Communication Tutorial", PS1, 8.
π HISTORY π
The inet protocol interface appeared in 4.2BSD. The "protocol cloning" code appeared in FreeBSD 2.1. like, she's been iconic since forever π
π CAVEATS π
okay bestie listen up because this one matters π«Ά The Internet protocol support is subject to change as the Internet protocols develop. Users should not depend on details of the current implementation, but rather the services exported. Fr fr, do not build your whole personality on the internals π
π
and that's the whole page, you ate that. this one's from Debian, dated December 31, 2024, and it's the INET(4) page β go forth and configure responsibly, mwah πβ¨π¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1983, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms