1

I have a ubuntu 14.10, and am trying to telnet into it via port 5060 but I keep failing. I always get the message "Connection closed by foreign host".

I checked my iptable, it is default policy to ACCEPT, and ufw is inactive.

So I should be able to telnet into 5060 right? What else could be blocking it?

root@server:/var/log# iptables --list
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
root@server:/var/log# 

root@server:/var/log# ufw status
Status: inactive
root@server:/var/log# 

but telneting just gives me this.

user@host ~
$ telnet 192.168.0.5 5060
Trying 192.168.0.5...
Connected to 192.168.0.5.
Escape character is '^]'.
Connection closed by foreign host.

I want to run sip traffic on that port later but I can't even open the port right now.

Thanks guys

1 Answer 1

2

The output you provided actually means that port 5060 is open and nothing is blocking it, because you got Connected to 192.168.0.5. But the connection got terminated by the destination host as soon as it was created, that's why it directly goes to Connection closed by foreign host. This is probably because the program that is listening on that port is expecting some data as soon as a connection was created, or maybe the program needs to be configured in a different way.

If a port is being blocked (or is not open), you will never see Conneted to <IPaddress>, but you'd see something like this:

Trying <IPaddress>...
telnet: Unable to connect to remote host: Connection refused

You did the right thing by checking iptables, but since there are no rules blocking the traffic, you can further verify that the server in fact has port 5060 open by executing the following command:

netstat -ntlup | grep 5060

You should see an output like this:

tcp        0      0 0.0.0.0:5060             0.0.0.0:*               LISTEN
1
  • Thanks Alaa, we found out that our sip application that is suppose to listen on 5060 is not listening on it for some reason. thanks for your help.
    – D.Zou
    Aug 5, 2014 at 13:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .