S6-TCPSERVER-ACCESS(8)
π S6-TCPSERVER-ACCESS(8) β command-line TCP access control tool π
okay so bestie, this is the s6-tcpserver-access page from the System Manager's Manual, and honestly? it's a little bouncer for your TCP connections and it slays. let's get into it π«Ά
β¨ SYNOPSIS β¨
s6-tcpserver-access [-v verbosity] [-W | -w] [-D | -d] [-H] [-h]
[-R | -r] [-P | -p] [-l localname] [-B banner]
[-t timeout] [-i rulesdir | -x rulesfile] prog...
πΈ DESCRIPTION πΈ
so s6-tcpserver-access is meant to be run after s6-tcpserver(8) and before the application program on the s6-tcpserver(8) command line β literally the exact same slot where tcpwrappers' tcpd goes, iykyk. and it also does some fine-tuning on a TCP socket while it's there. multitasking icon π
it first makes sure it's running under a UCSPI server tool like s6-tcpserver(8) or its stripped-down little sibling s6-tcpserverd(8). vibe check passed or it's not playing.
then it checks that the remote end of the connection fits the accepted criteria defined by the database sitting in rulesdir or rulesfile. if the database says "no bestie", the program exits 1. periodt.
it also sets up a few additional environment variables.
and then it executes into prog... β unless the first matching rule in the rule database includes instructions to override prog... in which case, plot twist, that happens instead π
one thing to know: s6-tcpserver-access may perform several DNS queries. for efficiency purposes it does as many of them as possible in parallel (efficient queen β¨). however, if it's asked to do an IDENT query, it does not parallelize that with DNS queries. keep that in mind when you're estimating a proper timeout value, fr fr.
π Access rule checking π
s6-tcpserver-access checks its client connection against a ruleset. this ruleset can be implemented:
- either in the filesystem as an arborescence of directories and files, if the
-ioption has been given. this option is the most flexible one: the directory format is simple enough for scripts to understand and modify it, and the ruleset can be changed dynamically. this is practical, for instance, for roaming users. π - or in a CDB file[1], if the
-xoption has been given. this option is the most efficient one if the ruleset is static enough: a lot less system calls are needed to perform searches in a CDB than in the filesystem. β‘
the exact format of the ruleset is described on the s6-accessrules-cdb-from-fs(8) page. go read it, bestie, it's giving essential lore.
so the flow is: s6-tcpserver-access first gets the remote address ip of the client and converts it to canonical form. then it checks it with the s6_accessrules_keycheck_ip46() function. (refer to s6-accessrules(7).) in other words, it tries to match broader and broader network prefixes of ip, from ip4/ip_32 to ip4/0.0.0.0_0 if ip is v4, or from ip6/ip_128 to ip6/::_0 if ip is v6. and if the result is:
S6_ACCESSRULES_ERRORβ it immediately exits111.S6_ACCESSRULES_DENYβ it immediately exits1.S6_ACCESSRULES_ALLOWβ it grants access. πS6_ACCESSRULES_NOTFOUNDβ more information is needed.
in that last case, if DNS lookups have been deactivated (-H) then access is denied. but if s6-tcpserver-access is authorized to perform DNS lookups, then it gets the remote name of the client, remotehost, and checks it with the s6_accessrules_keycheck_reversedns() function. (refer to s6-accessrules(7).) in other words, it tries to match shorter and shorter suffixes of remotehost, from reversedns/remotehost to reversedns/@. this time, the connection is denied if the result is anything else than S6_ACCESSRULES_ALLOW. no partial credit, bestie π
note that even if the access check succeeds, the connection can still be denied if paranoid mode has been requested (-p) and a forward DNS query on remotehost does not match ip. trust issues, honestly. valid though.
π§ Environment and executable modifications π§
s6-tcpserver-access interprets non-empty env subdirectories and exec files it finds in the matching rule of the ruleset, as explained in the s6-accessrules-cdb-from-fs(8) page.
an env subdirectory is interpreted as if the s6-envdir(8) command had been called before executing prog: the environment is modified according to the contents of env.
an exec file containing newprog completely bypasses the rest of s6-tcpserver-access' command line. after environment modifications, if any, s6-tcpserver-access execs into execlineb -c newprog. main character energy, it just takes over π
π OPTIONS π
-vverbosity β be more or less verbose, i.e. print more or less information to stderr:0β only log error messages.1β only log error and warning messages, and accepted connections. this is the default.2β also log rejected connections and more warning messages.3β also log detailed warning messages from DNS and IDENT resolution.
-Wβ non-fatal. if errors happen during DNS or IDENT resolution, the connection process is not aborted. however, incorrect or incomplete results might still prevent a legitimate connection from being authenticated against a DNS name. this is the default.-wβ fatal. errors during DNS or IDENT resolution will drop the connection. harsh but honest π-Dβ disable Nagle's algorithm. sets theTCP_NODELAYflag on the network socket.-dβ enable Nagle's algorithm. this is the default.-Hβ disable DNS lookups for the${PROTO}LOCALHOSTand${PROTO}REMOTEHOSTenvironment variables. the default, when this option is not given, is to try and read them from DNS.-hβ consult/etc/hostsbefore DNS. the default, when this option is not given, is to ignore/etc/hosts. note 1: the-Hoption overrides this one β no DNS lookups means that the hosts database won't be consulted either. note 2: if a name is obtained via the hosts database instead of DNS, any-pchecks will be disabled for it.-Rβ disable IDENT lookups for the${PROTO}REMOTEINFOenvironment variable. this is the default.-rβ enable IDENT lookups. this should only be done for legacy programs that need it. like, legacy legacy π«-Pβ no paranoid DNS lookups. this is the default.-pβ paranoid. after looking up a name for the remote host,s6-tcpserver-accesswill lookup IP addresses for this name, and drop the connection if none of the results matches the address the connection is originating from. note that this still does not replace real authentication via a cryptographic protocol. (say it louder for the people in the back π’)-llocalname β use localname as the value for the${PROTO}LOCALHOSTenvironment variable, instead of looking it up in the DNS.-Bbanner β print banner to the network as soon as the connection is attempted, even before checking client credentials. the point is to speed up network protocols that start with a server-side message. first impressions, literally π-ttimeout β set a timeout on all the operations performed bys6-tcpserver-access. if it is not able to do its job in timeout milliseconds, it will instantly exit99. the default is0, meaning no such timeout.-irulesdir β check client credentials against a filesystem-based database in the rulesdir directory.-xrulesfile β check client credentials against a CDB[1] database in the rulesfile file.-iand-xare mutually exclusive. if none of those options is given, no credential checking will be performed.
π¦ ENVIRONMENT π¦
s6-tcpserver-access expects to inherit some environment variables from its parent:
PROTOβ normallyTCP, but could be anything else.${PROTO}LOCALIPβ the local address of the socket.${PROTO}LOCALPORTβ the local port of the socket.${PROTO}REMOTEIPβ the remote address of the socket, i.e. the client's IP address.${PROTO}REMOTEPORTβ the remote port of the socket.
additionally, it exports the following variables before executing into prog...:
${PROTO}REMOTEIPβ via the IDENT protocol if the-roption has been given.${PROTO}REMOTEHOSTβ set to the remote host name obtained from a DNS lookup. unset if the-Hoption has been given.${PROTO}LOCALHOSTβ set to the local host name obtained from a DNS lookup. if the-loption has been given, set to localname instead.${PROTO}REMOTEINFOβ normally unset, but set to the information retrieved from${PROTO}REMOTEIPvia the IDENT protocol if the-roption has been given.
also, the access rules database can instruct s6-tcpserver-access to set up, or unset, more environment variables, depending on the client address. so many little knobs, obsessed πΈ
π SEE ALSO π
s6-accessrules(7), s6-accessrules-cdb-from-fs(8), s6-envdir(8), s6-tcpserver(8), s6-tcpserverd(8)
[1] https://en.wikipedia.org/wiki/Cdb_(software)
this man page is ported from the authoritative documentation at: https://skarnet.org/software/s6-networking/s6-tcpserver-access.html
π AUTHORS π
Laurent Bercot Alexis <flexibeast@gmail.com> (man page port)
and that's the whole page, bestie, no cap π«Ά so much love to the Debian crew β this one's from Debian, dated November 20, 2023, and it's the S6-TCPSERVER-ACCESS(8) page, now serving looks. go forth and configure responsibly β¨ππ
π¦ where this page comes from
- nixpkgs unstable: s6-networking 2.8.0.1
- nixpkgs unstable: s6-networking-man-pages 2.7.2.1.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms