If you’ve not seen the echo service before, it is a very simple Linux service that simply echos back whatever it is sent. Here I use telnet to connect to the service (port 7) and type ABC:
Once I press enter, the ABC is sent back to me.
This can be a handy tool in the early stages of developing a networked program.
At the moment, I’m testing ideas for a program on an Arduino that will make a network connection to a Raspberry Pi. By running the echo service and WireShark on the Raspberry Pi, I can simply monitor the network traffic to see if packets are being created and sent like I want without writing any code on the Raspberry Pi.
This allows me to test ideas on the Arduino to verify that the concept works without having to also write code for the Raspberry Pi. Once I know the proof of concept works, then I can proceed to working on code for the Raspberry Pi.
echo is NOT enabled by default. Which is fine. I have never allowed it to run on a production system. I’m sure some hacker could take advantage of it in some way. But it is useful on a development system.
echo is part of the openbsd-inetd package which can be installed with:
sudo apt-get update sudo apt-get install openbsd-inetd
Once installed, you will need to edit /etc/inetd.conf and add a few lines using the editor of your choice (the commented lines were already present, I just added the echo lines):
#:INTERNAL: Internal services #discard stream tcp nowait root internal #discard dgram udp wait root internal #daytime stream tcp nowait root internal #time stream tcp nowait root internal echo stream tcp nowait root internal echo dgram udp wait root internal
To restart inetd:
sudo service openbsd-inetd restart
Finally, verify that echo service is connected properly:
netstat -a | less Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:echo *:* LISTEN tcp 0 0 *:5900 *:* LISTEN tcp 0 0 *:x11 *:* LISTEN tcp 0 0 *:http *:* LISTEN tcp 0 0 *:ftp *:* LISTEN tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:telnet *:* LISTEN tcp 0 0 localhost:gpsd *:* LISTEN udp 0 0 *:echo *:* udp 0 0 localhost:ntp *:* udp 0 0 *:ntp *:*