No route to host : ssh Error

8,786

The source 172.16.101.213 and the destination 172.16.13.151 are not on the same network (based on the netmask 255.255.240.0). Thus your laptop is sending the packets to the default gateway 172.16.96.1, which apparently does not know the route to your PC.

Share:
8,786

Related videos on Youtube

Joe
Author by

Joe

Updated on September 18, 2022

Comments

  • Joe
    Joe almost 2 years

    I have a laptop and a PC ([email protected]) , I usually connect the laptop to PC via ssh. But now when I try ssh -X [email protected] , it is showing the following error ssh: connect to host 172.16.13.151 port 22: No route to host. What could be the possible problem ?

    Output of ifconfig is the following:

    eth0
    Link encap:Ethernet  HWaddr 2c:41:38:0d:bb:a2
    UP BROADCAST MULTICAST  MTU:1500  Metric:1
    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:127.0.0.1  Mask:255.0.0.0
    inet6 addr: ::1/128 Scope:Host
    UP LOOPBACK RUNNING  MTU:65536  Metric:1
    RX packets:1750 errors:0 dropped:0 overruns:0 frame:0
    TX packets:1750 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0 
    RX bytes:134949 (134.9 KB)  TX bytes:134949 (134.9 KB)
    
    wlan0
    Link encap:Ethernet  HWaddr d0:df:9a:76:18:1e
    inet addr:172.16.101.213  Bcast:172.16.111.255  Mask:255.255.240.0
    inet6 addr: fe80::d2df:9aff:fe76:181e/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
    RX packets:595855 errors:0 dropped:0 overruns:0 frame:0
    TX packets:37917 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000 
    RX bytes:138691381 (138.6 MB)  TX bytes:4733835 (4.7 MB)
    

    output of route is the following :

    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    default         172.16.96.1     0.0.0.0         UG    0      0        0 wlan0
    link-local      *               255.255.0.0     U     1000   0        0 wlan0
    172.16.96.0     *               255.255.240.0   U     2      0        0 wlan0
    

    Output of traceroute 172.16.13.151 gives

    traceroute to 172.16.13.151 (172.16.13.151), 30 hops max, 60 byte packets  
    1  172.16.96.5 (172.16.96.5)  456.381 ms  457.461 ms  457.448 ms       
    2  172.16.96.5 (172.16.96.5)  5007.656 ms !H  5007.665 ms !H  5015.906 ms !H
    
    • Admin
      Admin over 7 years
      You can diagnose this further with traceroute command. Most likely your gateway router 172.16.96.1 is missing the route to 172.16.13.0/24 network.
    • Admin
      Admin over 7 years
      Please edit debug output like this always into the question, it is difficult to read from the comments.
    • Admin
      Admin over 7 years
      I've modified the question including the traceroute part
    • Admin
      Admin over 7 years
      @TeroKilkanen If it was missing the route it shouldn't take 5 seconds to respond. More likely it does have a route and sends ARP queries for the destination. But nobody answers the ARP queries so after 5 seconds it times out.
  • Joe
    Joe over 7 years
    @Johan MyréenI think you are making a mistake here https://en.wikipedia.org/wiki/IPv4_subnetting_reference, both source and destination are on the same network here . Subnet mask is 255.255.240.0 not 255.255.255.0, both are different. Here the default gateway is the IP of the router and it should be able to find out the PC. Please correct me if I am wrong. I also don't think taht host and the destination has to be on the same network inorder for SSH connections.
  • Johan Myréen
    Johan Myréen over 7 years
    In hex notation the netmask is ff.ff.f0.00, the source address is ac.10.65.d5 and the destination address ac.10.0d.97. The first five hex digits should be equal for the addresses to be on the same subnet.
  • Joe
    Joe over 7 years
    @Johan Myréen Thank you for correcting my mistake. But it is not necessary that the host and the destination should be on the same network inorder for ssh connection, right ?
  • Johan Myréen
    Johan Myréen over 7 years
    No, of course it's not necessary for the the source and destination to be on the same subnet, otherwise ssh would not go very far. I jumped to this conclusion based on that you had two similar addresses and just a default route in addition to that. Btw, what is the 172.16.96.5 address in your traceroute listing above?
  • Joe
    Joe over 7 years
    @Johan Myréen Actually I'm using my college wifi here and the routers are DHCP servers. So the gateway changes as I move around.
  • Johan Myréen
    Johan Myréen over 7 years
    Ok, here's one more wild guess: maybe the subnetworks don't "see" each other, and your PC and laptop were originally on the same subnetwork by pure luck.