xref: /freebsd/contrib/blocklist/bin/blacklistd.conf.5 (revision 513c4e20790a24526cb1c2f5a4725971a09d928a)
15f4c09ddSEd Maste.\" $NetBSD: blacklistd.conf.5,v 1.9 2019/11/06 20:33:30 para Exp $
25f4c09ddSEd Maste.\"
35f4c09ddSEd Maste.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
45f4c09ddSEd Maste.\" All rights reserved.
55f4c09ddSEd Maste.\"
65f4c09ddSEd Maste.\" This code is derived from software contributed to The NetBSD Foundation
75f4c09ddSEd Maste.\" by Christos Zoulas.
85f4c09ddSEd Maste.\"
95f4c09ddSEd Maste.\" Redistribution and use in source and binary forms, with or without
105f4c09ddSEd Maste.\" modification, are permitted provided that the following conditions
115f4c09ddSEd Maste.\" are met:
125f4c09ddSEd Maste.\" 1. Redistributions of source code must retain the above copyright
135f4c09ddSEd Maste.\"    notice, this list of conditions and the following disclaimer.
145f4c09ddSEd Maste.\" 2. Redistributions in binary form must reproduce the above copyright
155f4c09ddSEd Maste.\"    notice, this list of conditions and the following disclaimer in the
165f4c09ddSEd Maste.\"    documentation and/or other materials provided with the distribution.
175f4c09ddSEd Maste.\"
185f4c09ddSEd Maste.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
195f4c09ddSEd Maste.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
205f4c09ddSEd Maste.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
215f4c09ddSEd Maste.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
225f4c09ddSEd Maste.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
235f4c09ddSEd Maste.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
245f4c09ddSEd Maste.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
255f4c09ddSEd Maste.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
265f4c09ddSEd Maste.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
275f4c09ddSEd Maste.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
285f4c09ddSEd Maste.\" POSSIBILITY OF SUCH DAMAGE.
295f4c09ddSEd Maste.\"
305f4c09ddSEd Maste.Dd May 18, 2020
315f4c09ddSEd Maste.Dt BLACKLISTD.CONF 5
325f4c09ddSEd Maste.Os
335f4c09ddSEd Maste.Sh NAME
345f4c09ddSEd Maste.Nm blacklistd.conf
355f4c09ddSEd Maste.Nd configuration file format for blacklistd
365f4c09ddSEd Maste.Sh DESCRIPTION
375f4c09ddSEd MasteThe
385f4c09ddSEd Maste.Nm
395f4c09ddSEd Mastefile contains configuration entries for
405f4c09ddSEd Maste.Xr blacklistd 8
415f4c09ddSEd Mastein a fashion similar to
425f4c09ddSEd Maste.Xr inetd.conf 5 .
435f4c09ddSEd MasteOnly one entry per line is permitted.
445f4c09ddSEd MasteEvery entry must have all fields populated.
455f4c09ddSEd MasteEach field can be separated by a tab or a space.
465f4c09ddSEd MasteComments are denoted by a
475f4c09ddSEd Maste.Dq #
485f4c09ddSEd Masteat the beginning of a line.
495f4c09ddSEd Maste.Pp
505f4c09ddSEd MasteThere are two kinds of configuration lines,
515f4c09ddSEd Maste.Va local
525f4c09ddSEd Masteand
535f4c09ddSEd Maste.Va remote .
545f4c09ddSEd MasteBy default, configuration lines are
555f4c09ddSEd Maste.Va local ,
565f4c09ddSEd Mastei.e. the address specified refers to the addresses on the local machine.
575f4c09ddSEd MasteTo switch to between
585f4c09ddSEd Maste.Va local
595f4c09ddSEd Masteand
605f4c09ddSEd Maste.Va remote
615f4c09ddSEd Masteconfiguration lines you can specify the stanzas:
625f4c09ddSEd Maste.Dq [local]
635f4c09ddSEd Masteand
645f4c09ddSEd Maste.Dq [remote] .
655f4c09ddSEd Maste.Pp
665f4c09ddSEd MasteOn
675f4c09ddSEd Maste.Va local
685f4c09ddSEd Masteand
695f4c09ddSEd Maste.Va remote
705f4c09ddSEd Mastelines
715f4c09ddSEd Maste.Dq *
725f4c09ddSEd Mastemeans use the default, or wildcard match.
735f4c09ddSEd MasteIn addition, for
745f4c09ddSEd Maste.Va remote
755f4c09ddSEd Mastelines
765f4c09ddSEd Maste.Dq =
775f4c09ddSEd Mastemeans use the values from the matched
785f4c09ddSEd Maste.Va local
795f4c09ddSEd Masteconfiguration line.
805f4c09ddSEd Maste.Pp
815f4c09ddSEd MasteThe first four fields,
825f4c09ddSEd Maste.Va location ,
835f4c09ddSEd Maste.Va type ,
845f4c09ddSEd Maste.Va proto ,
855f4c09ddSEd Masteand
865f4c09ddSEd Maste.Va owner
875f4c09ddSEd Masteare used to match the
885f4c09ddSEd Maste.Va local
895f4c09ddSEd Masteor
905f4c09ddSEd Maste.Va remote
915f4c09ddSEd Masteaddresses, whereas the last 3 fields
925f4c09ddSEd Maste.Va name ,
935f4c09ddSEd Maste.Va nfail ,
945f4c09ddSEd Masteand
955f4c09ddSEd Maste.Va disable
965f4c09ddSEd Masteare used to modify the filtering action.
975f4c09ddSEd Maste.Pp
985f4c09ddSEd MasteThe first field denotes the
995f4c09ddSEd Maste.Va location
1005f4c09ddSEd Masteas an address, mask, and port.
1015f4c09ddSEd MasteThe syntax for the
1025f4c09ddSEd Maste.Va location
1035f4c09ddSEd Masteis:
1045f4c09ddSEd Maste.Bd -literal -offset indent
1055f4c09ddSEd Maste	[<address>|<interface>][/<mask>][:<port>]
1065f4c09ddSEd Maste.Ed
1075f4c09ddSEd Maste.Pp
1085f4c09ddSEd MasteThe
1095f4c09ddSEd Maste.Dv address
1105f4c09ddSEd Mastecan be an IPv4 address in numeric format, an IPv6 address
1115f4c09ddSEd Mastein numeric format and enclosed by square brackets, or an interface name.
1125f4c09ddSEd MasteMask modifiers are not allowed on interfaces because interfaces
1135f4c09ddSEd Mastecan have multiple addresses in different protocols where the mask has a different
1145f4c09ddSEd Mastesize.
1155f4c09ddSEd Maste.Pp
1165f4c09ddSEd MasteThe
1175f4c09ddSEd Maste.Dv mask
1185f4c09ddSEd Masteis always numeric, but the
1195f4c09ddSEd Maste.Dv port
1205f4c09ddSEd Mastecan be either numeric or symbolic.
1215f4c09ddSEd Maste.Pp
1225f4c09ddSEd MasteThe second field is the socket
1235f4c09ddSEd Maste.Va type :
1245f4c09ddSEd Maste.Dv stream ,
1255f4c09ddSEd Maste.Dv dgram ,
1265f4c09ddSEd Masteor numeric.
1275f4c09ddSEd MasteThe third field is the
1285f4c09ddSEd Maste.Va protocol :
1295f4c09ddSEd Maste.Dv tcp ,
1305f4c09ddSEd Maste.Dv udp ,
1315f4c09ddSEd Maste.Dv tcp6 ,
1325f4c09ddSEd Maste.Dv udp6 ,
1335f4c09ddSEd Masteor numeric.
1345f4c09ddSEd MasteThe fourth field is the effective user
1355f4c09ddSEd Maste.Va ( owner )
1365f4c09ddSEd Masteof the daemon process reporting the event,
1375f4c09ddSEd Masteeither as a username or a userid.
1385f4c09ddSEd Maste.Pp
1395f4c09ddSEd MasteThe rest of the fields control the behavior of the filter.
1405f4c09ddSEd Maste.Pp
1415f4c09ddSEd MasteThe
1425f4c09ddSEd Maste.Va name
1435f4c09ddSEd Mastefield, is the name of the packet filter rule to be used.
1445f4c09ddSEd MasteIf the
1455f4c09ddSEd Maste.Va name
1465f4c09ddSEd Mastestarts with a
1475f4c09ddSEd Maste.Dq - ,
1485f4c09ddSEd Mastethen the default rulename is prepended to the given name.
1495f4c09ddSEd MasteIf the
1505f4c09ddSEd Maste.Dv name
1515f4c09ddSEd Mastecontains a
1525f4c09ddSEd Maste.Dq / ,
1535f4c09ddSEd Mastethe remaining portion of the name is interpreted as the mask to be
1545f4c09ddSEd Masteapplied to the address specified in the rule, causing a single rule violation to
1555f4c09ddSEd Masteblock the entire subnet for the configured prefix.
1565f4c09ddSEd Maste.Pp
1575f4c09ddSEd MasteThe
1585f4c09ddSEd Maste.Va nfail
1595f4c09ddSEd Mastefield contains the number of failed attempts before access is blocked,
1605f4c09ddSEd Mastedefaulting to
1615f4c09ddSEd Maste.Dq *
1625f4c09ddSEd Mastemeaning never, and the last field
1635f4c09ddSEd Maste.Va disable
1645f4c09ddSEd Mastespecifies the amount of time since the last access that the blocking
1655f4c09ddSEd Masterule should be active, defaulting to
1665f4c09ddSEd Maste.Dq *
1675f4c09ddSEd Mastemeaning forever.
1685f4c09ddSEd MasteThe default unit for
1695f4c09ddSEd Maste.Va disable
1705f4c09ddSEd Masteis seconds, but one can specify suffixes for different units, such as
1715f4c09ddSEd Maste.Dq m
1725f4c09ddSEd Mastefor minutes
1735f4c09ddSEd Maste.Dq h
1745f4c09ddSEd Mastefor hours and
1755f4c09ddSEd Maste.Dq d
1765f4c09ddSEd Mastefor days.
1775f4c09ddSEd Maste.Pp
1785f4c09ddSEd MasteMatching is done first by checking the
1795f4c09ddSEd Maste.Va local
1805f4c09ddSEd Masterules individually, in the order of the most specific to the least specific.
1815f4c09ddSEd MasteIf a match is found, then the
1825f4c09ddSEd Maste.Va remote
1835f4c09ddSEd Masterules are applied.
1845f4c09ddSEd MasteThe
1855f4c09ddSEd Maste.Va name ,
1865f4c09ddSEd Maste.Va nfail ,
1875f4c09ddSEd Masteand
1885f4c09ddSEd Maste.Va disable
1895f4c09ddSEd Mastefields can be altered by the
1905f4c09ddSEd Maste.Va remote
1915f4c09ddSEd Masterule that matched.
1925f4c09ddSEd Maste.Pp
1935f4c09ddSEd MasteThe
1945f4c09ddSEd Maste.Va remote
1955f4c09ddSEd Masterules can be used for allowing specific addresses, changing the mask
1965f4c09ddSEd Mastesize, the rule that the packet filter uses, the number of failed attempts,
1975f4c09ddSEd Masteor the block duration.
1985f4c09ddSEd Maste.Sh FILES
1995f4c09ddSEd Maste.Bl -tag -width /etc/blacklistd.conf -compact
2005f4c09ddSEd Maste.It Pa /etc/blacklistd.conf
2015f4c09ddSEd MasteConfiguration file.
2025f4c09ddSEd Maste.El
2035f4c09ddSEd Maste.Sh EXAMPLES
2045f4c09ddSEd Maste.Bd -literal -offset 8n
2055f4c09ddSEd Maste# Block ssh, after 3 attempts for 6 hours on the bnx0 interface
2065f4c09ddSEd Maste[local]
2075f4c09ddSEd Maste# location	type	proto	owner	name	nfail	duration
2085f4c09ddSEd Mastebnx0:ssh	*	*	*	*	3	6h
2095f4c09ddSEd Maste[remote]
2105f4c09ddSEd Maste# Never block 1.2.3.4
2115f4c09ddSEd Maste1.2.3.4:ssh	*	*	*	*	*	*
212*513c4e20SEd Maste# For addresses coming from 8.8.0.0/16 block whole /24 networks instead of
2135f4c09ddSEd Maste# individual hosts, but keep the rest of the blocking parameters the same.
2145f4c09ddSEd Maste8.8.0.0/16:ssh	*	*	*	/24	=	=
2155f4c09ddSEd Maste.Ed
2165f4c09ddSEd Maste.Sh SEE ALSO
2175f4c09ddSEd Maste.Xr blacklistctl 8 ,
2185f4c09ddSEd Maste.Xr blacklistd 8
2195f4c09ddSEd Maste.Sh HISTORY
2205f4c09ddSEd Maste.Nm
2215f4c09ddSEd Mastefirst appeared in
2225f4c09ddSEd Maste.Nx 7 .
2235f4c09ddSEd Maste.Fx
2245f4c09ddSEd Mastesupport for
2255f4c09ddSEd Maste.Nm
2265f4c09ddSEd Mastewas implemented in
2275f4c09ddSEd Maste.Fx 11 .
2285f4c09ddSEd Maste.Sh AUTHORS
2295f4c09ddSEd Maste.An Christos Zoulas
230