INET(4)
π INET(4) π β the Internet protocol family, bestie edition
okay so welcome to inet(4), from the Kernel Interfaces Manual section, and no cap this one is a whole vibe. it's the Internet protocol family. let's get into it π«Ά
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <netinet/in.h>
π DESCRIPTION π
so the Internet protocol family is literally a whole collection of protocols, right? and they're all layered on top of the Internet Protocol (IP) transport layer, using the Internet address format. that's the whole thing. that's the assignment and she ATE π
the Internet family gives you protocol support for the SOCK_STREAM, SOCK_DGRAM, and SOCK_RAW socket types β and the SOCK_RAW interface is the one that gives you access to the IP protocol itself. main character energy fr fr π₯
π ADDRESSING π
Internet addresses are four byte quantities, stored in network standard format. and heads up, on little endian machines β like the alpha, amd64 and i386 β these are word and byte reversed. so like, mind the gap bestie π
the include file <netinet/in.h> defines this address as a discriminated union.
sockets bound to the Internet protocol family use this addressing structure, and yes we're pasting it exactly, do not come for me:
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];
};
so you can create sockets with the local address INADDR_ANY to get that βwildcardβ matching on incoming messages β it's giving "I'll take whatever shows up" β¨
and the address in a connect(2) or sendto(2) call can also be given as INADDR_ANY, which in that context means βthis hostβ. same girl, different outfit π
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. conditional queen π
β PROTOCOLS β
the Internet protocol family is comprised of:
- the IP network protocol
- Internet Control Message Protocol (ICMP)
- Internet Group Management Protocol (IGMP)
- Transmission Control Protocol (TCP)
- User Datagram Protocol (UDP)
TCP is what supports the SOCK_STREAM abstraction, while UDP supports the SOCK_DGRAM abstraction. a raw interface to IP is available by creating an Internet socket of type SOCK_RAW. and the ICMP message protocol is accessible from a raw socket. periodt π
the inet address on an interface consists of the address itself, the netmask, and either the broadcast address (in case of a broadcast interface) or the peer's address (in case of a point-to-point interface).
the following ioctl(2) commands are provided for a datagram socket in the Internet domain β presenting the lineup πΈ:
SIOCAIFADDRβ Add address to an interface. The command requiresstruct in_aliasreqas argument.SIOCDIFADDRβ Delete address from an interface. The command requiresstruct ifreqas argument.SIOCGIFADDRSIOCGIFBRDADDRSIOCGIFDSTADDRSIOCGIFNETMASKβ Return address information from interface. The returned value is instruct ifreq. This way of address information retrieval is obsoleted, and a preferred way is to use thegetifaddrs(3)API.
ok so real talk: those last four are obsoleted, bestie. they still work, but the glow-up is getifaddrs(3). don't be the last one at the party π«Ά
π¦ MIB Variables π¦
a number of variables are implemented in the net.inet branch of the sysctl(3) MIB. and besides the variables supported by the transport protocols (for those, go consult the respective manual pages, iykyk), the following general variables are defined:
IPCTL_FORWARDING(ip.forwarding) β Boolean: enable/disable forwarding of IP packets. Defaults to off.IPCTL_SENDREDIRECTS(ip.redirect) β Boolean: enable/disable 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.IPCTL_DEFTTL(ip.ttl) β Integer: default time-to-live (βTTLβ) to use for outgoing IP packets.IPCTL_ACCEPTSOURCEROUTE(ip.accept_sourceroute) β Boolean: enable/disable accepting of source-routed IP packets (default false).IPCTL_SOURCEROUTE(ip.sourceroute) β Boolean: enable/disable forwarding of source-routed IP packets (default false).ip.process_optionsβ Integer: control IP options processing.- set it to 0 β all IP options in the incoming packets will be ignored, and the packets will be passed unmodified.
- set it to 1 β IP options in the incoming packets will be processed accordingly.
- set it to 2 β an ICMP βprohibited by filterβ message will be sent back in response to incoming packets with IP options.
- Default is 1.
- This
sysctl(8)variable affects packets destined for a local host as well as packets forwarded to some other host. so like, both, bestie.
ip.rfc6864β Boolean: control 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. TheFreeBSDimplementation sets it to zero. Enabled by default. β¨ip.random_idβ Boolean: control IP IDs generation behaviour. Setting thissysctl(8)to 1 causes the ID field in non-atomic IP datagrams (or all IP datagrams, ifip.rfc6864is 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 is 0 (sequential IP IDs).
- IPv6 flow IDs and fragment IDs are always random. no cap.
ip.maxfragsβ Integer: maximum number of fragments the host will accept and simultaneously hold across all reassembly queues in all VNETs.0β reassembly is disabled.-1β this limit is not applied.- This limit is recalculated when the number of mbuf clusters is changed.
- This is a global limit.
ip.maxfragpacketsβ Integer: maximum number of fragmented packets the host will accept and simultaneously hold in the reassembly queue for a particular VNET.0β the host will not accept any fragmented packets for that VNET.-1β 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.
ip.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 of
ip.maxfragpacketschanges. - This is a per-VNET limit.
- This limit is recalculated when the number of mbuf clusters is changed or when the value of
ip.maxfragsperpacketβ Integer: maximum number of fragments the host will accept and hold in the reassembly queue for a packet.0β the host will not accept any fragmented packets for the VNET.- This is a per-VNET limit.
π SEE ALSO π
ioctl(2), socket(2), getifaddrs(3), sysctl(3), icmp(4), intro(4), ip(4), ipfirewall(4), route(4), tcp(4), udp(4), pfil(9)
β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. and the βprotocol cloningβ code appeared in FreeBSD 2.1. vintage but make it iconic π
π CAVEATS π
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.
like, do NOT get attached to implementation details bestie, she's a moving target π
and that's the whole page!! π this one came from the Debian crew, dated August 14, 2018, filed under INET(4) β stay safe out there, and remember: read the docs, love yourself, and never trust an undocumented limit. mwah πβ¨π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1983, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms