Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've searched solution in Google for 3 days, when I decided to write here. I have a router, so in my house is WLAN. I use laptop when I stay at home. In another city in my office I have a second computer (PC). I can connect with this PC using SSH protocol. Unfortunately I can't connect with my laptop from PC. When I try to do this, I see the statement:

ssh: connect to host XX.XX.XX.XX port 22: Network is unreachable

Daemon SSHD is running in my laptop. What is interesting, this connection worked correctly a few months ago, but I reinstalled the SSHD and now is the problem.

/sbin/route shows:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         UG    0      0        0 wlan0     *        U     2      0        0 wlan0

/sbin/ifconfig prints:

eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:169 errors:0 dropped:0 overruns:0 frame:0
          TX packets:169 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:13189 (12.8 Kb)  TX bytes:13189 (12.8 Kb)

wlan0     Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          inet addr:  Bcast:  Mask:
          RX packets:76455 errors:0 dropped:0 overruns:0 frame:0
          TX packets:82766 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:53583517 (51.1 Mb)  TX bytes:13182981 (12.5 Mb)

I suppose, that the problem is related with settings of gateway, but I'm layman in this subject (Computer Network). This suggestion is due to my Google's investigation.

share|improve this question
Just to make sure: is your laptop at home behind a router that has a static IP? Is your router/firewall at home configured to forward the SSH port (22 by default) to your laptop? – Joseph R. Jun 29 '14 at 12:29
I bet you need use your companies VPN connection. – Red Cricket Jun 29 '14 at 17:34

Since you have not provided additional information, I will elaborate on my comment as to what I think is happening here.

Just to preface this, please forgive me for assuming you have made this mistake, I'm just going on what you're saying:

I'm layman in this subject (Computer Network)."

I believe that you are trying to use your home computer's private IP address when trying to SSH into it from work. This would produce one of two behaviors depending on the network configuration at your home and workplace:

  1. Your home and office networks use the same private IP address space, in which case, you will either be attempting to connect to a machine at your office that just happens to have the same private IP as your home computer1 or (more likely), you will not find such a machine on your office network and will get something along the lines of "Host unreachable" or "No route to host".
  2. Your home and office networks use different private IP address spaces (the by far more likely scenario), in which case, you're attempting to reach a machine in a different private network and you'll get the "Network unreachable" error.

Then why did it work before?

My guess is, this happened at a time you had brought your laptop to work, in which case, both devices were on the same private network. When you reported it "working" you were thinking that the issue has to do with your SSH daemon rather than with your network configuration.

So how can I work around this?

There are several solutions. Here are some that I can think of:

  1. As per Red Cricket's comment, make sure your laptop is connected to your company's VPN before you leave the house in the morning. This will make both devices appear to be on the same private network.
  2. Shell out for a static IP address provided by your ISP. This may be too costly and too risky2 for the benefits you get, though. It's up to you to decide.
  3. Look at a dynamic DNS service. Most of these come at a cost, too; but there seem to be some sites willing to offer up the service for free. Again, you need to mind your security and privacy in this case.
  4. You can use Dropbox to run simple commands/scripts on your laptop. DISCLAIMER: I have not tried this method and am not necessarily vouching for its success/security.

Note that in both solutions 2 and 3 above, you'll need some mechanism to forward the SSH port that your laptop listens on (this is port 22 by default) from your gateway router (where the connection will come) to your laptop. This can often be accomplished from within the router itself. In your router's interface, look at NAT (network address translation) options. In some routers, this may be filed under a "Gaming" category.

1 Of course that office machine may or may not have an SSH daemon running. So you'll either be asked to provide credentials for the user you're trying to log in as (the odds of those being the same as your laptop's credentials are also slim) or you'll get a "Connection refused" error since there is no SSH listener running (on the standard SSH port) of that device.

2 Your device having a static IP makes it a stationary target for attackers, so you might want to think about firewalling and tight access control in that case.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.