ssh连接有时会打印“无路由到主机”,有时会正常连接

时间:2014-03-25 02:01:31

标签: ssh routing remote-access host openssh

我有两台笔记本电脑: - Debian挤压的第一个,通过以太网连接,IP地址为192.168.0.2 - 第二个与Ubuntu 12.10通过wlan连接,并具有IP地址192.168.0.9

问题是: - 如果我尝试从第一个到第二个使用ssh,我得到这个结果:

laptop1@192.168.0.2:~$ ssh laptop2@192.168.0.9
"ssh : connect to host 192.168.0.9 port 22: No route to host "
  • 如果我尝试从第二个到第一个使用ssh,它会成功连接到第一个。

    laptop2@192.168.0.9:~$ ssh laptop1@192.168.0.1
    
  • 现在,如果我再次尝试从第一个到第二个连接,它会成功连接到第二个

    laptop1@192.168.0.2:~$ ssh laptop2@192.168.0.9
    

但是几分钟之后如果我尝试从第一个到第二个使用ssh,我仍然得到这个结果:

"ssh : connect to host 192.168.0.9 port 22: No route to host ".

在laptop1上键入命令arp我注意到,当laptop2的ip地址消失时,我无法从laptop1连接到laptop2。

laptop1@192.168.0.2:~$ sudo arp

Address       HWtype   HWAddress        Flags  Mask  Iface
192.168.0.1   ether   00:1b:2f:3f:b5:a2   C           eth0
192.168.0.9   ether   e4:d5:3d:03:3b:ed   C           eth0
几分钟后......

laptop1@192.168.0.2:~$ sudo arp

Address       HWtype   HWAddress        Flags  Mask  Iface
192.168.0.1   ether   00:1b:2f:3f:b5:a2   C           eth0

有人明白为什么会这样?我该如何解决?

我发布了我的两台笔记本电脑的更多信息:

  • 为laptop1:

    laptop1@192.168.0.2:~$ sudo ifconfig
    eth0      Link encap:Ethernet  HWaddr 20:cf:30:08:e0:82  
      inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0
      inet6 addr: fe80::22cf:30ff:fe08:e082/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:29290 errors:0 dropped:0 overruns:0 frame:0
      TX packets:28325 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:20301572 (19.3 MiB)  TX bytes:11035023 (10.5 MiB)
      Interrupt:30 
    
    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:16436  Metric:1
      RX packets:1440 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1440 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:166450 (162.5 KiB)  TX bytes:166450 (162.5 KiB)
    
    wlan0     Link encap:Ethernet  HWaddr 74:f0:6d:76:79:93  
      inet6 addr: fe80::76f0:6dff:fe76:7993/64 Scope:Link
      UP BROADCAST MULTICAST  MTU:1500  Metric:1
      RX packets:42 errors:0 dropped:0 overruns:0 frame:0
      TX packets:81 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:10888 (10.6 KiB)  TX bytes:16236 (15.8 KiB)
    
    
    
    laptop1@192.168.0.2:~$ sudo route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.0.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
    0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 eth0
    
  • 为laptop2:

    laptop2@192.168.0.9:~$ sudo ifconfig
    eth0      Link encap:Ethernet  HWaddr 04:7d:7b:1e:47:8b  
      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:16436  Metric:1
      RX packets:124 errors:0 dropped:0 overruns:0 frame:0
      TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:10373 (10.3 KB)  TX bytes:10373 (10.3 KB)
    
    wlan0     Link encap:Ethernet  HWaddr e4:d5:3d:03:3b:ed  
      inet addr:192.168.0.9  Bcast:192.168.0.255  Mask:255.255.255.0
      inet6 addr: fe80::e6d5:3dff:fe03:3bed/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:1434 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1329 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:1274245 (1.2 MB)  TX bytes:188474 (188.4 KB)
    
    
    
    laptop2@192.168.0.9:~$ sudo route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 wlan0
    192.168.0.0     0.0.0.0         255.255.255.0   U     9      0        0 wlan0
    

0 个答案:

没有答案