5.1.2.1. Setting a Trap

5.1.2.1. Setting a Trap

One important feature of xinetd is its ability to add hosts to a global no_access list. Hosts on this list are denied subsequent connections to services managed by xinetd for a specified length of time or until xinetd is restarted. This is accomplished using the SENSOR attribute. This technique is an easy way to block hosts attempting to port scan the server.

The first step in setting up a SENSOR is to choose a service you do not plan on using. For this example, Telnet is used.

Edit the file /etc/xinetd.d/telnet and change the flags line to read:

         flags = SENSOR 
      

Add the following line within the braces:

         deny_time = 30 
      

This denies the host that attempted to connect to the port for 30 minutes. Other acceptable values for the deny_time attribute are FOREVER, which keeps the ban in effect until xinetd is restarted, and NEVER, which allows the connection and logs it.

Finally, the last line should read:

         disable = no 
      

While using SENSOR is a good way to detect and stop connections from nefarious hosts, it has two drawbacks: