Limit the number of Telnet sessions coming from the same remote system

Posted on in Categories , , , last updated January 5, 2007

Q. How do I configure telnet server so that I can limit the number of Telnet sessions coming from the same remote system under Cent OS Linux?

A. You can use iptables to limit the number of Telnet sessions coming from the same remote system. However iptables may take some time. CentOS (and Redhat Linux, Fedora Core) use xinetd to manage telnet server. You need to set per_source variable.

The per_source config directive can define the limit for Telnet sessions coming from the same remote system.

Open /etc/xinetd.d/telnet file
# vi /etc/xinetd.d/telnet
Append/modify per_source as follows:
per_source = 2

Save and close the file. At the end your file should read as follows:
service telnet

{
        disable = no
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.telnetd
        log_on_failure  += USERID
        per_source      = 2
}

Restart xinetd service:
# /etc/init.d/xinetd restart

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Leave a Comment