我需要在 Linux/Debian 上有一个 echo 服务器用于调试目的,我意识到“/etc/services”中已经显示了一个分配的端口来执行此操作,它是端口 7 TCP/UDP。
是否可以在 Linux (Debian) 上打开此端口?如果没有,有什么替代方案?
答案1
要在 Debian 中设置 echo 服务,您可以安装xinetd
:
apt-get install xinetd
比你必须将disable
指令更改为no
in /etc/xinetd.d/echo
;或者,如果该文件不存在,请按如下所示创建它:
# default: off
# description: An xinetd internal service which echo's characters back to
# clients.
# This is the tcp version.
service echo
{
disable = no
type = INTERNAL
id = echo-stream
socket_type = stream
protocol = tcp
user = root
wait = no
}
# This is the udp version.
service echo
{
disable = yes
type = INTERNAL
id = echo-dgram
socket_type = dgram
protocol = udp
user = root
wait = yes
}
设置disable = no
或创建文件后,重新启动xinetd
:
sudo service xinetd restart
测试echo
TCP 服务:
$nc localhost echo
testing...
testing...
xxxx
xxxx
^C