bind xinetd to external port

June 19, 2017 55 views
Firewall Debian

I've setup a hello world service:

#!/bin/bash
echo "hello"

with xinetd:

service hello
{
    disable     = no
    socket_type = stream
    protocol    = tcp
    port        = 8000
    wait        = no
    user        = root
    server      = /home/github/hello
}

and opened port 8000 with ufw:

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
8000                       ALLOW       Anywhere
8000 on eth0               ALLOW       Anywhere
22                         ALLOW       Anywhere (v6)
8000                       ALLOW       Anywhere (v6)
8000 on eth0               ALLOW       Anywhere (v6)

This works locally:

$ nc 127.0.0.1 8000
hello

but not from a remote machine:

 nc [filtered ip address] 8000
<hangs>

Any idea what I'm doing wrong?

1 Answer

Hi @andrewddixon

Try checking the listening services:

sudo lsof -iTCP -sTCP:LISTEN -P

Otherwise, try stopping xinetd and starting it in debug mode:

sudo service xinetd stop

sudo xinetd -d
  • Thanks for the help! lsof shows that xinetd was listening to the port:

    $ sudo lsof -iTCP -sTCP:LISTEN -P
    COMMAND     PID        USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
    rpcbind     435        root    8u  IPv4  10184      0t0  TCP *:111 (LISTEN)
    rpcbind     435        root   11u  IPv6  10187      0t0  TCP *:111 (LISTEN)
    rpc.statd   449       statd    9u  IPv4  10319      0t0  TCP *:36684 (LISTEN)
    rpc.statd   449       statd   11u  IPv6  10325      0t0  TCP *:42283 (LISTEN)
    exim4       736 Debian-exim    4u  IPv4  11448      0t0  TCP localhost:25 (LISTEN)
    exim4       736 Debian-exim    5u  IPv6  11449      0t0  TCP ip6-localhost:25 (LISTEN)
    sshd      15653        root    3u  IPv4  28700      0t0  TCP *:22 (LISTEN)
    sshd      15653        root    4u  IPv6  28709      0t0  TCP *:22 (LISTEN)
    xinetd    19341        root    5u  IPv4  51803      0t0  TCP *:7 (LISTEN)
    xinetd    19341        root    8u  IPv4  51805      0t0  TCP *:8000 (LISTEN)
    

    I wound up restarting ufw and now everything works. I thought I'd tried that before posting but ¯_(ツ)_/¯

Have another answer? Share your knowledge.