LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Telnet not working for localhost (https://www.linuxquestions.org/questions/linux-newbie-8/telnet-not-working-for-localhost-875049/)

Abhy 04-14-2011 01:25 PM

Telnet not working for localhost
 
Hi,

I've tried searching for this peculiar behavior, but couldn't find a solution that works for it - I have installed Redhat on my system and have a listener running on port 7878.
I wanted to check if the port is accessible from a machine on the network, and so i telnet-ed from a remote machine and it worked. Now comes the weird problem - I used the same command (telnet xxx.xxx.xxx.xxx 7878) locally and it was able to telnet. However, if I try to connect using localhost, meaning, "telnet localhost 7878" or "telnet 127.0.0.1 7878", it gives me the following error:

Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host: Connection refused

Here is my /etc/hosts entry:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

xxx.xxx.xxx.xxx mcname.domain.com mcname



and the resolv.conf file:

# Generated by NetworkManager
search domain.com
nameserver abc.abc.abc.abc


Not sure where the problem is. I expect telnet to connect irrespective of whether i use the IP address OR localhost when i use telnet locally.

I appreciate any help and/or insights into this.

Regards,
Abhy

acid_kewpie 04-14-2011 01:31 PM

you really shouldn't be describing this any *anything* to do with telnet. You're totally misusing telnet for other purposes (which is fine for the troubleshooting uses here) but this is not a telnet issue in any way. It just sounds like whatever daemon is listening on that port is not configured to listen on every IP. Just run "netstat -plnt" to see what's listening where. Either that or you're firewalled by iptables / netfilter, but that's not nearly as likely.

Abhy 04-14-2011 02:59 PM

I'm sorry if this came off as a telnet issue. I can totally see my post title giving that impression; apologize for the miscommunication. Using telnet for debugging connectivity issues has become a (questionable?) second nature to me, so I didn't really care.

Well the problem, as you point out and I agree, is not with telnet, but the way my system handles IP addresses. The system apparently identifies localhost and xxx.xxx.xxx.xxx as two different entities, which I'm pretty sure is a configuration fault.

acid_kewpie 04-15-2011 12:25 AM

yes, me to. Irrelevant of the "localhost" name, you have two different IP addresses being used, and that's what will be the point of difference in the two scenarios

themanwhowas 04-15-2011 02:19 AM

localhost or 127.0.0.1 is the loopback address. The packets never leave the machine. telneting your network ip address, 192.168.12.12 or whatever, sends the packets to your router via your network adapter (eth0 or something) which then sends it back. telneting to 127.0.0.1 sends the packets to lo. run ifconfig and you will see eth0 and lo.

Perhaps the daemon in question is only listening on eth0. perhaps you have iptables forwarding packets sent to eth0. I wouldn't think that it's a configuration fault.

ps. I also use telnet for checking many things such as mail servers. I thought this was common

acid_kewpie 04-15-2011 02:56 AM

Quote:

Originally Posted by themanwhowas (Post 4325218)
localhost or 127.0.0.1 is the loopback address. The packets never leave the machine. telneting your network ip address, 192.168.12.12 or whatever, sends the packets to your router via your network adapter (eth0 or something) which then sends it back. telneting to 127.0.0.1 sends the packets to lo. run ifconfig and you will see eth0 and lo.

Perhaps the daemon in question is only listening on eth0. perhaps you have iptables forwarding packets sent to eth0. I wouldn't think that it's a configuration fault.

ps. I also use telnet for checking many things such as mail servers. I thought this was common

Erm, no. That's really not right. The packets sent to a local eth interface will still not leave the machine as there is no need.
And using telnet for debugging IS very common, and good, but as it's a total misuse of telnet's code it can never be an issue with telnet.


All times are GMT -5. The time now is 11:29 AM.