LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-26-2012, 08:16 AM   #1
tezarin
Member
 
Registered: Nov 2007
Posts: 133

Rep: Reputation: 0
SSH doesn't work: No route to host


Hi all,

I was connected to a mail server via PuTTY and all of a sudden the connecttion dropped and I've tried everything and no luck. My SSH is not the default port 22. Here are the commands I ran,

Code:
# ssh -l root mailservername -p [my ssh port number]
ssh: connect to host mailservername port [my ssh port number]: No route to host
# ssh -l root IPnumber -p [my ssh port number]
ssh: connect to host IPnumber port [my ssh port number]: No route to host
Ping works just fine

ssh localhost works just fine

Code:
#ps aux | grep ssh
root 6583    0.0   0.1  69452  15740   tty1   S+   14:05  0:00 ssh root@localhost –p [my ssh port number]
root 6584    0.0   0.0  88996  3492      ?       Ss    14:05  0:00 sshd:  root@pts.0
root 17285  0.0   0.0  61664  1188      ?       Ss    14:26  0:00  /user/sbin/sshd
root 29790  0.0   0.0  61208   772 pts/0      S+    14:49  0:00 grep ssh
Restarted iptables didn’t help either. SELinux is already in Permissive mode:

Code:
#getenforce
Permissive
Installed NMAP and scanned the ports and didn't see the SSH:
Code:
#nmap
Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2012-01-25
Interesting ports on localhost.localdomain (127.0.0.1)
Not shown: 1669 closed ports
PORT STATE SERVICE
[number]/tcp open smtp
[number]/tcp open http
[number]/tcp open pop3
[number]/tcp open netbios-ssn
[number]/tcp open imap
[number]/tcp open https
[number]/tcp Microsoft-ds
[number]/tcp open smtps
[number]/tcp open ipp
[number]/tcp open imaps
[number]/tcp open pop3s
traceroute from a client to this mail server returns:
Code:
# traceroute [mailservername]
traceroute to mailservername (mail server IP), 30 hops max, 60 byte packets
 1  mailserver.domain.com (mail server IP)  8.850 ms !X  8.841 ms !X  8.832 ms !X
And from the mailserver to a client gave me a long output with some *** at the end. I was at the console and took pictures of the output but since that output was long couldn't capture it.

The mail server is up and running but SSH to that box just doesn't work.

would someone please help me fix this issue? I'd really appreciate it.

Thank you,
t

Last edited by tezarin; 01-26-2012 at 08:34 AM.
 
Old 01-26-2012, 09:01 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Are you connecting from your LAN or from the outside?
Try to restart the ssh daemon.

Kind regards
 
Old 01-26-2012, 09:22 AM   #3
tezarin
Member
 
Registered: Nov 2007
Posts: 133

Original Poster
Rep: Reputation: 0
Thanks repo.

I'm trying to SSH from inside the LAN. But the mail server doesn't have a LAN address(i.e. 192.x.x.x). It has only one interface which should be accessible from anywhere. The ifconfig returns only 127.x.x.x address and that external address.

I've already rebooted the ssh many times, no luck. ssh localhost on the mail server works just fine.
 
Old 01-26-2012, 09:24 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Did it worked before?
Did you forwarded port 22 on the router?
Try to connect from the outside.

Kind regards
 
Old 01-26-2012, 09:28 AM   #5
tezarin
Member
 
Registered: Nov 2007
Posts: 133

Original Poster
Rep: Reputation: 0
Thanks, I'll have to try to connect from the outside when I get home.

It has always been working just fine. The SSH port is not 22, have changed that years ago and apparently forwarding was working until couple days ago.
 
Old 01-26-2012, 12:58 PM   #6
kbscores
Member
 
Registered: Oct 2011
Location: USA
Distribution: Red Hat
Posts: 259
Blog Entries: 9

Rep: Reputation: 32
If you have telnet on your localhost try doing:

Code:
# telnet localhost [port]
If it comes back with a similar message "no route to host" then it means a firewall is blocking that port.

If you get "connection refused" then odds are ssh is configured to only allow local connections.

If it allows than problem is most likely external to server.

Also, another place to check is /etc/services file. Make sure it is configured for correct port or some other perhaps new service isn't trying to take that port.


ALSO - by default firewalls are configured to allow port 22. If ssh port is changed it really sounds like the firewall is blocking connect. Especially based on error message you are receiving.

Last edited by kbscores; 01-26-2012 at 01:00 PM. Reason: More information
 
Old 01-27-2012, 07:52 AM   #7
tezarin
Member
 
Registered: Nov 2007
Posts: 133

Original Poster
Rep: Reputation: 0
Thanks for your reply. I get a "connection refused" if I try port 22. If I try the port I configured to be my new SSH port, it says "no route to host". It has been working for years now and never had a problem with it and the firewall never blocked that before. Haven't installed a new thing on that machine either.

I tried accessing from outside of the LAN but same thing happened.

I did stop and start the iptable and still no luck. Maybe the firewall detected something and automatically all of a sudden blocked that port? How can I make the firewall not block that custom port now?

I did this and no luck:

Code:
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport {my ssh port} ACCEPT
Thanks

Last edited by tezarin; 01-27-2012 at 09:00 AM.
 
Old 01-27-2012, 11:43 AM   #8
tezarin
Member
 
Registered: Nov 2007
Posts: 133

Original Poster
Rep: Reputation: 0
This is what I found in each file:

iptables:
Code:
# Generated by iptables-save v1.3.5 on Fri Jan 27 12:16:54 2012
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [10396207:8077141142]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A INPUT -p tcp -m tcp --dport {my ssh port} -j ACCEPT
-A INPUT -p tcp -m tcp --dport {my ssh port} -j ACCEPT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp -m icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p esp -j ACCEPT
-A RH-Firewall-1-INPUT -p ah -j ACCEPT
-A RH-Firewall-1-INPUT -d 224.0.0.251 -p udp -m udp --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 110 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 143 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 465 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 7071 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 993 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 995 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Fri Jan 27 12:16:54 2012
hosts.deny:
Code:
nginx: .google.com
68.x.x.x : sshd
ALL: .ru
ALL: .cn
hosts.allow:
This file was empty
 
Old 01-30-2012, 05:11 AM   #9
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
try this command


Code:
#netstat -ntlp | grep (ssh port no)
 
  


Reply



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
[SOLVED] SSH no route to host error. can ssh outside lan, but not to clients on lan... jmd9qs Linux - Networking 3 01-21-2012 10:28 AM
Can ssh from a computer, but not into it (no route to host) Daravon Linux - Networking 7 04-11-2010 08:47 PM
ssh: connect to host .....No route to host soumyacs Linux - Newbie 5 10-27-2009 10:03 AM
SSH no route to host, also PING problem Z038 Linux - Networking 5 06-22-2008 05:59 PM
ssh: No route to host thanhvn Linux - Software 6 06-30-2005 07:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:50 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
Open Source Consulting | Domain Registration