{
    "mode": "man",
    "parameter": "hosts_access",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/hosts_access/5/json",
    "generated": "2026-06-02T19:34:30Z",
    "sections": {
        "NAME": {
            "content": "hostsaccess - format of host access control files\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This  manual  page  describes  a simple access control language that is based on client (host\nname/address, user name), and server (process name, host  name/address)  patterns.   Examples\nare  given at the end. The impatient reader is encouraged to skip to the EXAMPLES section for\na quick introduction.\n\nThe extended version of the access control language is described in the hostsoptions(5) doc‐\nument. Note that this language supersedes the meaning of shellcommand as documented below.\n\nIn  the following text, daemon is the process name of a network daemon process, and client is\nthe name and/or address of a host requesting service. Network daemon process names are speci‐\nfied in the inetd configuration file.\n",
            "subsections": []
        },
        "ACCESS CONTROL FILES": {
            "content": "The access control software consults two files. The search stops at the first match:\n\n•      Access  will  be  granted  when  a  (daemon,client)  pair  matches  an  entry  in  the\n/etc/hosts.allow file.\n\n•      Otherwise, access will be denied when a (daemon,client) pair matches an entry  in  the\n/etc/hosts.deny file.\n\n•      Otherwise, access will be granted.\n\nA  non-existing access control file is treated as if it were an empty file. Thus, access con‐\ntrol can be turned off by providing no access control files.\n",
            "subsections": []
        },
        "ACCESS CONTROL RULES": {
            "content": "Each access control file consists of zero or more lines of text.  These lines  are  processed\nin order of appearance. The search terminates when a match is found.\n\n•      A newline character is ignored when it is preceded by a backslash character. This per‐\nmits you to break up long lines so that they are easier to edit.\n\n•      Blank lines or lines that begin with a `#´ character are ignored.  This permits you to\ninsert comments and whitespace so that the tables are easier to read.\n\n•      All other lines should satisfy the following format, things between [] being optional:\n\ndaemonlist : clientlist [ : shellcommand ]\n\ndaemonlist  is  a  list  of one or more daemon process names (argv[0] values) or server port\nnumbers or wildcards (see below).\n\nclientlist is a list of one or more host names, host addresses, patterns or  wildcards  (see\nbelow) that will be matched against the client host name or address.\n\nThe more complex forms daemon@host and user@host are explained in the sections on server end‐\npoint patterns and on client username lookups, respectively.\n\nList elements should be separated by blanks and/or commas.\n\nWith the exception of NIS (YP) netgroup lookups, all access control checks are case  insensi‐\ntive.\n",
            "subsections": []
        },
        "PATTERNS": {
            "content": "The access control language implements the following patterns:\n\n•      A  string  that begins with a `.´ character. A host name is matched if the last compo‐\nnents of its name match the specified pattern.  For  example,  the  pattern  `.tue.nl´\nmatches the host name `wzv.win.tue.nl´.\n\n•      A  string  that  ends with a `.´ character. A host address is matched if its first nu‐\nmeric fields match the given string.  For example, the pattern `131.155.´ matches  the\naddress of (almost) every host on the Eindhoven University network (131.155.x.x).\n\n•      A string that begins with an `@´ character is treated as an NIS (formerly YP) netgroup\nname. A host name is matched if it is a host member of the  specified  netgroup.  Net‐\ngroup matches are not supported for daemon process names or for client user names.\n\n•      An  expression  of  the form `n.n.n.n/m.m.m.m´ is interpreted as a `net/mask´ pair. An\nIPv4 host address is matched if `net´ is equal to the bitwise AND of the  address  and\nthe `mask´. For example, the net/mask pattern `131.155.72.0/255.255.254.0´ matches ev‐\nery address in the range `131.155.72.0´ through  `131.155.73.255´.   `255.255.255.255´\nis not a valid mask value, so a single host can be matched just by its IP.\n\n•      An  expression  of  the  form  `n.n.n.n/mm' is interpreted as a `net/masklength' pair,\nwhere `mm' is the number of consecutive  `1'  bits  in  the  netmask  applied  to  the\n`n.n.n.n' address.\n\n•      An  expression of the form `[n:n:n:n:n:n:n:n]/m´ is interpreted as a `[net]/prefixlen´\npair. An IPv6 host address is matched if `prefixlen´ bits of `net´  is  equal  to  the\n`prefixlen´   bits   of   the   address.  For  example,  the  [net]/prefixlen  pattern\n`[3ffe:505:2:1::]/64´ matches every address  in  the  range  `3ffe:505:2:1::´  through\n`3ffe:505:2:1:ffff:ffff:ffff:ffff´.\n\n•      A  string  that  begins with a `/´ character is treated as a file name. A host name or\naddress is matched if it matches any host name or address pattern listed in the  named\nfile.  The  file  format  is zero or more lines with zero or more host name or address\npatterns separated by whitespace.  A file name pattern can be  used  anywhere  a  host\nname or address pattern can be used.\n\n•      Wildcards  `*´ and `?´ can be used to match hostnames or IP addresses.  This method of\nmatching cannot be used in conjunction with `net/mask´ matching, hostname matching be‐\nginning with `.´ or IP address matching ending with `.´.\n",
            "subsections": []
        },
        "WILDCARDS": {
            "content": "The access control language supports explicit wildcards:\n\nALL    The universal wildcard, always matches.\n\nLOCAL  Matches any host whose name does not contain a dot character.\n\nUNKNOWN\nMatches any user whose name is unknown, and matches any host whose name or address are\nunknown.  This pattern should be used with care: host names may be unavailable due  to\ntemporary  name  server problems. A network address will be unavailable when the soft‐\nware cannot figure out what type of network it is talking to.\n\nKNOWN  Matches any user whose name is known, and matches any host whose name and address  are\nknown.  This  pattern  should  be used with care: host names may be unavailable due to\ntemporary name server problems.  A network address will be unavailable when the  soft‐\nware cannot figure out what type of network it is talking to.\n\nPARANOID\nMatches  any  host  whose  name  does  not match its address.  When tcpd is built with\n-DPARANOID (default mode), it drops requests from such clients even before looking  at\nthe  access  control tables.  Build without -DPARANOID when you want more control over\nsuch requests.\n",
            "subsections": []
        },
        "OPERATORS": {
            "content": "EXCEPT Intended use is of the form: `list1 EXCEPT list2´; this construct  matches  anything\nthat matches list1 unless it matches list2.  The EXCEPT operator can be used in dae‐\nmonlists and in clientlists. The EXCEPT operator can be nested: if the control  lan‐\nguage  would  permit  the use of parentheses, `a EXCEPT b EXCEPT c´ would parse as `(a\nEXCEPT (b EXCEPT c))´.\n",
            "subsections": []
        },
        "SHELL COMMANDS": {
            "content": "If the first-matched access control rule contains a shell command, that command is  subjected\nto  %<letter>  substitutions  (see  next section).  The result is executed by a /bin/sh child\nprocess with standard input, output and error connected to /dev/null.  Specify an `&´ at  the\nend of the command if you do not want to wait until it has completed.\n\nShell  commands  should  not rely on the PATH setting of the inetd.  Instead, they should use\nabsolute path names, or they should begin with an explicit PATH=whatever statement.\n\nThe hostsoptions(5) document describes an alternative language that uses the  shell  command\nfield in a different and incompatible way.\n",
            "subsections": [
                {
                    "name": "% EXPANSIONS",
                    "content": "The following expansions are available within shell commands:\n\n%a (%A)\nThe client (server) host address.\n\n%c     Client  information: user@host, user@address, a host name, or just an address, depend‐\ning on how much information is available.\n\n%d     The daemon process name (argv[0] value).\n\n%h (%H)\nThe client (server) host name or address, if the host name is unavailable.\n\n%n (%N)\nThe client (server) host name (or \"unknown\" or \"paranoid\").\n\n%r (%R)\nThe clients (servers) port number (or \"0\").\n\n%p     The daemon process id.\n\n%s     Server information: daemon@host, daemon@address, or just a daemon name,  depending  on\nhow much information is available.\n\n%u     The client user name (or \"unknown\").\n\n%%     Expands to a single `%´ character.\n\nCharacters in % expansions that may confuse the shell are replaced by underscores.\n"
                }
            ]
        },
        "SERVER ENDPOINT PATTERNS": {
            "content": "In  order to distinguish clients by the network address that they connect to, use patterns of\nthe form:\n\nprocessname@hostpattern : clientlist ...\n\nPatterns like these can be used when the machine has different internet addresses  with  dif‐\nferent  internet  hostnames.  Service providers can use this facility to offer FTP, GOPHER or\nWWW archives with internet names that may even belong to different  organizations.  See  also\nthe `twist´ option in the hostsoptions(5) document. Some systems (Solaris, FreeBSD) can have\nmore than one internet address on one physical interface; with other systems you may have  to\nresort to SLIP or PPP pseudo interfaces that live in a dedicated network address space.\n\nThe  hostpattern obeys the same syntax rules as host names and addresses in clientlist con‐\ntext. Usually, server endpoint information is available only  with  connection-oriented  ser‐\nvices.\n",
            "subsections": []
        },
        "CLIENT USERNAME LOOKUP": {
            "content": "When the client host supports the RFC 931 protocol or one of its descendants (TAP, IDENT, RFC\n1413) the wrapper programs can retrieve additional information about the owner of  a  connec‐\ntion.  Client  username  information, when available, is logged together with the client host\nname, and can be used to match patterns like:\n\ndaemonlist : ... userpattern@hostpattern ...\n\nThe daemon wrappers can be configured at compile time to perform rule-driven username lookups\n(default)  or  to  always  interrogate  the client host.  In the case of rule-driven username\nlookups, the above rule would cause username lookup only when both the  daemonlist  and  the\nhostpattern match.\n\nA  user  pattern has the same syntax as a daemon process pattern, so the same wildcards apply\n(netgroup membership is not supported).  One  should  not  get  carried  away  with  username\nlookups, though.\n\n•      The  client  username  information cannot be trusted when it is needed most, i.e. when\nthe client system has been compromised.  In general, ALL and (UN)KNOWN  are  the  only\nuser name patterns that make sense.\n\n•      Username  lookups  are possible only with TCP-based services, and only when the client\nhost runs a suitable daemon; in all other cases the result is \"unknown\".\n\n•      A well-known UNIX kernel bug may cause loss  of  service  when  username  lookups  are\nblocked  by  a firewall. The wrapper README document describes a procedure to find out\nif your kernel has this bug.\n\n•      Username lookups may cause noticeable delays for non-UNIX users.  The default  timeout\nfor  username  lookups  is  10 seconds: too short to cope with slow networks, but long\nenough to irritate PC users.\n\nSelective username lookups can alleviate the last problem. For example, a rule like:\n\ndaemonlist : @pcnetgroup ALL@ALL\n\nwould match members of the pc netgroup without doing  username  lookups,  but  would  perform\nusername lookups with all other systems.\n",
            "subsections": []
        },
        "DETECTING ADDRESS SPOOFING ATTACKS": {
            "content": "A  flaw  in  the sequence number generator of many TCP/IP implementations allows intruders to\neasily impersonate trusted hosts and to break in via, for example, the remote shell  service.\nThe  IDENT  (RFC931 etc.)  service can be used to detect such and other host address spoofing\nattacks.\n\nBefore accepting a client request, the wrappers can use the IDENT service to  find  out  that\nthe  client  did not send the request at all.  When the client host provides IDENT service, a\nnegative IDENT lookup result (the client matches `UNKNOWN@host´) is strong evidence of a host\nspoofing attack.\n\nA  positive  IDENT lookup result (the client matches `KNOWN@host´) is less trustworthy. It is\npossible for an intruder to spoof both the client connection and the IDENT  lookup,  although\ndoing  so  is  much  harder  than  spoofing just a client connection. It may also be that the\nclient´s IDENT server is lying.\n\nNote: IDENT lookups don´t work with UDP services.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "The language is flexible enough that different types of access  control  policy  can  be  ex‐\npressed  with  a  minimum  of fuss. Although the language uses two access control tables, the\nmost common policies can be implemented with one of the tables being trivial or even empty.\n\nWhen reading the examples below it is important to realize that the allow  table  is  scanned\nbefore  the  deny table, that the search terminates when a match is found, and that access is\ngranted when no match is found at all.\n\nThe examples use host and domain names. They can be improved by including address and/or net‐\nwork/netmask information, to reduce the impact of temporary name server lookup failures.\n",
            "subsections": []
        },
        "MOSTLY CLOSED": {
            "content": "In this case, access is denied by default. Only explicitly authorized hosts are permitted ac‐\ncess.\n\nThe default policy (no access) is implemented with a trivial deny file:\n\n/etc/hosts.deny:\nALL: ALL\n\nThis denies all service to all hosts, unless they are permitted access by entries in the  al‐\nlow file.\n\nThe explicitly authorized hosts are listed in the allow file.  For example:\n\n/etc/hosts.allow:\nALL: LOCAL @somenetgroup\nALL: .foobar.edu EXCEPT terminalserver.foobar.edu\n\nThe  first  rule  permits access from hosts in the local domain (no `.´ in the host name) and\nfrom members of the somenetgroup netgroup.  The second rule permits access from all hosts in\nthe  foobar.edu  domain  (notice  the leading dot), with the exception of terminalserver.foo‐\nbar.edu.\n",
            "subsections": []
        },
        "MOSTLY OPEN": {
            "content": "Here, access is granted by default; only explicitly specified hosts are refused service.\n\nThe default policy (access granted) makes the allow file redundant so that it can be omitted.\nThe explicitly non-authorized hosts are listed in the deny file. For example:\n\n/etc/hosts.deny:\nALL: some.host.name, .some.domain\nALL EXCEPT in.fingerd: other.host.name, .other.domain\n\nThe first rule denies some hosts and domains all services; the second rule still permits fin‐\nger requests from other hosts and domains.\n",
            "subsections": []
        },
        "BOOBY TRAPS": {
            "content": "The next example permits tftp requests from hosts in the local  domain  (notice  the  leading\ndot).   Requests  from  any  other hosts are denied.  Instead of the requested file, a finger\nprobe is sent to the offending host. The result is mailed to the superuser.\n\n/etc/hosts.allow:\nin.tftpd: LOCAL, .my.domain\n\n/etc/hosts.deny:\nin.tftpd: ALL: (/usr/sbin/safefinger -l @%h | \\\n/usr/bin/mail -s %d-%h root) &\n\nThe safefinger command comes with the tcpd wrapper and should be  installed  in  a  suitable\nplace. It limits possible damage from data sent by the remote finger server.  It gives better\nprotection than the standard finger command.\n\nThe expansion of the %h (client host) and %d (service name) sequences  is  described  in  the\nsection on shell commands.\n\nWarning:  do  not  booby-trap your finger daemon, unless you are prepared for infinite finger\nloops.\n\nOn network firewall systems this trick can be carried  even  further.   The  typical  network\nfirewall  only  provides a limited set of services to the outer world. All other services can\nbe \"bugged\" just like the above tftp example. The result is an excellent  early-warning  sys‐\ntem.\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "An  error  is  reported  when a syntax error is found in a host access control rule; when the\nlength of an access control rule exceeds the capacity of an internal buffer; when  an  access\ncontrol rule is not terminated by a newline character; when the result of %<letter> expansion\nwould overflow an internal buffer; when a system call fails that shouldn´t.  All problems are\nreported via the syslog daemon.\n",
            "subsections": []
        },
        "FILES": {
            "content": "/etc/hosts.allow, (daemon,client) pairs that are granted access.\n/etc/hosts.deny, (daemon,client) pairs that are denied access.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "hostsoptions(5) extended syntax.\ntcpd(8) tcp/ip daemon wrapper program.\ntcpdchk(8), tcpdmatch(8), test programs.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "If  a name server lookup times out, the host name will not be available to the access control\nsoftware, even though the host is registered.\n\nDomain name server lookups are case insensitive; NIS (formerly YP) netgroup lookups are  case\nsensitive.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Wietse Venema (wietse@wzv.win.tue.nl)\nDepartment of Mathematics and Computing Science\nEindhoven University of Technology\nDen Dolech 2, P.O. Box 513,\n5600 MB Eindhoven, The Netherlands\n\n\n\n\nHOSTSACCESS(5)",
            "subsections": []
        }
    },
    "summary": "hostsaccess - format of host access control files",
    "flags": [],
    "examples": [
        "The language is flexible enough that different types of access  control  policy  can  be  ex‐",
        "pressed  with  a  minimum  of fuss. Although the language uses two access control tables, the",
        "most common policies can be implemented with one of the tables being trivial or even empty.",
        "When reading the examples below it is important to realize that the allow  table  is  scanned",
        "before  the  deny table, that the search terminates when a match is found, and that access is",
        "granted when no match is found at all.",
        "The examples use host and domain names. They can be improved by including address and/or net‐",
        "work/netmask information, to reduce the impact of temporary name server lookup failures."
    ],
    "see_also": [
        {
            "name": "hostsoptions",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/hostsoptions/5/json"
        },
        {
            "name": "tcpd",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tcpd/8/json"
        },
        {
            "name": "tcpdchk",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tcpdchk/8/json"
        },
        {
            "name": "tcpdmatch",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/tcpdmatch/8/json"
        }
    ]
}