|
NAMEknockd - port-knock serverSYNOPSISknockd [options]DESCRIPTIONknockd is a port-knock server. It listens to all traffic on an ethernet (or PPP) interface, looking for special "knock" sequences of port-hits. A client makes these port-hits by sending a TCP (or UDP) packet to a port on the server. This port need not be open -- since knockd listens at the link-layer level, it sees all traffic even if it's destined for a closed port. When the server detects a specific sequence of port-hits, it runs a command defined in its configuration file. This can be used to open up holes in a firewall for quick access.COMMANDLINE OPTIONS
CONFIGURATIONknockd reads all knock/event sets from a configuration file. Each knock/event begins with a title marker, in the form [name], where name is the name of the event that will appear in the log. A special marker, [options], is used to define global options.Example #1:This example uses two knocks. The first will allow the
knocker to access port 22 (SSH), and the second will close the port when the
knocker is complete. As you can see, this could be useful if you run a very
restrictive (DENY policy) firewall and would like to access it discreetly.
[options] logfile = /var/log/knockd.log [openSSH] sequence = 7000,8000,9000 seq_timeout = 10 tcpflags = syn command = /usr/sbin/iptables -A INPUT -s %IP% --dport 22 -j ACCEPT [closeSSH] sequence = 9000,8000,7000 seq_timeout = 10 tcpflags = syn command = /usr/sbin/iptables -D INPUT -s %IP% --dport 22 -j ACCEPT Example #2:This example uses a single knock to control access to
port 22 (SSH). After receiving a successful knock, the daemon will run the
start_command, wait for the time specified in cmd_timeout, then
execute the stop_command. This is useful to automatically close the
door behind a knocker. The knock sequence uses both UDP and TCP ports.
[options] logfile = /var/log/knockd.log [opencloseSSH] sequence = 2222:udp,3333:tcp,4444:udp seq_timeout = 15 tcpflags = syn,ack start_command = /usr/sbin/iptables -A INPUT -s %IP% -p tcp --syn -j ACCEPT cmd_timeout = 5 stop_command = /usr/sbin/iptables -D INPUT -s %IP% -p tcp --syn -j ACCEPT Example #3:This example doesn't use a single, fixed knock sequence
to trigger an event, but a set of sequences taken from a sequence file (one
time sequences), specified by the one_time_sequences directive. After
each successful knock, the used sequence will be invalidated and the next
sequence from the sequence file has to be used for a successful knock. This
prevents an attacker from doing a replay attack after having discovered a
sequence (eg, while sniffing the network).
[options] logfile = /var/log/knockd.log [opencloseSMTP] one_time_sequences = /etc/knockd/smtp_sequences seq_timeout = 15 tcpflags = fin,!ack start_command = /usr/sbin/iptables -A INPUT -s %IP% -p tcp --dport 25 -j ACCEPT cmd_timeout = 5 stop_command = /usr/sbin/iptables -D INPUT -s %IP% -p tcp --dport 25 -j ACCEPT CONFIGURATION: GLOBAL DIRECTIVES
CONFIGURATION: KNOCK/EVENT DIRECTIVES
SECURITY NOTESUsing the -l or --lookup commandline option to resolve DNS names for log entries may be a security risk! An attacker may find out the first port of a sequence if he can monitor the DNS traffic of the host running knockd. Also a host supposed to be stealth (eg, dropping packets to closed TCP ports instead of replying with an ACK+RST packet) may give itself away by resolving a DNS name if an attacker manages to hit the first (unknown) port of a sequence.SEE ALSOknock is the accompanying port-knock client, though telnet or netcat could be used for simple TCP knocks instead. For more advanced knocks, see hping, sendip or packit.AUTHORJudd Vinet <jvinet@zeroflux.org>
Visit the GSP FreeBSD Man Page Interface. |