LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2011, 01:25 PM   #1
Abhy
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Rep: Reputation: 0
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
 
Old 04-14-2011, 01:31 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
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.
 
Old 04-14-2011, 02:59 PM   #3
Abhy
LQ Newbie
 
Registered: Jul 2010
Posts: 3

Original Poster
Rep: Reputation: 0
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.

Last edited by Abhy; 04-14-2011 at 04:34 PM.
 
Old 04-15-2011, 12:25 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
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
 
Old 04-15-2011, 02:19 AM   #5
themanwhowas
Member
 
Registered: Nov 2005
Distribution: CentOS 5, Fedora 23
Posts: 216

Rep: Reputation: 29
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
 
Old 04-15-2011, 02:56 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
Quote:
Originally Posted by themanwhowas View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can telnet to localhost but not IP address lpwevers Linux - Networking 5 07-16-2009 03:10 AM
Can ping to localhost but cannot telnet sreeramabsc Linux - Networking 5 04-02-2006 06:46 AM
Telnet problem and localhost zillah Linux - Wireless Networking 6 06-07-2005 02:34 PM
can not telnet localhost 25 but telnet dowell.exper.dynserv.com 25 exper Linux - Software 0 02-25-2004 05:13 AM
Telnet localhost and telnet not from localhost for IMAP services seb77 Linux - Networking 1 10-15-2003 01:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration