Hmm, your question seems to require a list of the IP's. You can do this fairly easily on the server side with (whatever your OS's equivalent) the FreeBSD
command. Parsing the output for
(23 being the telnet port) should not be to hard. There are even a couple CPAN modules that will help with easy IP Addr parsing.
Doing it this way is going to be much easier than a client side solution, IMHO.