在 Linux/Debian 上打开端口 7(回显端口)

Bri*_*SP2 5 linux networking debian tcp

我的 Linux/Debian 上需要一个回显服务器用于调试目的,我意识到在“/etc/services”中显示了一个已分配的端口来执行此操作,并且它是端口 7 TCP/UDP。

是否可以在 Linux (Debian) 上打开此端口?如果没有,有什么替代方案?

Rui*_*iro 5

要在 Debian 中设置 echo 服务,您可以安装xinetd:

apt-get install xinetd
Run Code Online (Sandbox Code Playgroud)

比您必须将disable指令更改为noin /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
}
Run Code Online (Sandbox Code Playgroud)

设置disable = no或创建文件后,重新启动xinetd:

sudo service xinetd restart
Run Code Online (Sandbox Code Playgroud)

测试echoTCP 服务:

$nc localhost echo
testing...
testing...
xxxx
xxxx
^C
Run Code Online (Sandbox Code Playgroud)

  • 启用 UDP 回显不是一个好主意... (3认同)