0
I want to check if I get any incoming telnet request. After doing google, I found out that tcpdump
can be used for this purpose. This is the tcpdump
command I would use.
$ tcpdump -i wlan0 -w telReqCapt.pcap 'dest host <myIpAddress> and port 23'
However I am not able to think of a way so that this monitoring is ALWAYS done. How do I do this ?
I have thought of few approach.
After everytime I log-in, I will run the
tcpdump
command. However this has to be done manually everytime.I will add the
tcpdump
command in me~/.bashrc
so that everytime I open the terminal, thetcpdump
command will run. But I dont know what will happen if I open two terminals (or two bash session) at same time. I feel there will be an issue because both thetcpdump
will try to write to same file.Write a bash script containing the
tcpdump
command and make it run everytime system boots usingupstart
(/etc/init/
)(I use ubuntu) or by putting the script in/etc/init.d
.
I think approach 3 is best suited for my needs, because I want to monitor if I get incoming telnet requests for the entire time (since my machine boots, untill it is powered off).
However please let me know if this approach has any problem with it ? Can I start tcpdump
everytime my system boots ? Is there anyuthing I need to take care of while following this approach. Any performance issues ?
Finally, is there ANY OTHER way I can use tcpdump
to capture incoming telnet
requests all the time (since the time the machine boots up untill it is powered off).
Just thinking out loud, why not let Netcat listen on TCP/23, forward the traffic to an alternative TCP port where the telnet daemon is listening on and let Netcat log everything to a file? TCP Dump seems to be quite "heavy" for just this job. – Jeroen – 2015-11-01T11:44:09.467
@Jeroen-ITNerdbox thank you for the suggestion. I will try to learn
netcat
. I recently learnedtcpdump
so I was thinking I will use it to see if i get any telnet requests .. – sps – 2015-11-01T11:52:53.700Don't use tpcdump. Use iptables. – Konrad Gajewski – 2015-11-02T17:58:58.930