You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

笔记本与树莓派3点对点网络连接失败:ssh报no route to host

Hey Justin, let's tackle this frustrating "no route to host" error you're hitting with your point-to-point network between Ubuntu 16.04 Xenial and Raspberry Pi 3 Raspbian Stretch. I’ve worked through similar issues before, so let’s go through targeted steps to get this sorted:

1. First, Confirm Physical & NIC Recognition
  • If you’re using a wired point-to-point connection, double-check that you’re using a cross-over cable (or a modern auto-sensing cable — older hardware might need a dedicated cross-over). For WiFi, ensure both devices are connected to the same Ad-hoc network.
  • On your Ubuntu laptop, run ip link show — look for the NIC you’re using (e.g., eth0 or wlan0) and confirm its status is UP (no DOWN or error messages). Do the same on the Pi with the same command.
2. Verify Static IP Configuration

Since you mentioned editing /etc/network/interfaces, let’s make sure those configs are correct for point-to-point:

  • Both devices must be on the exact same subnet. For example, set your Ubuntu to 192.168.10.1/24 and the Pi to 192.168.10.2/24.
  • Example Ubuntu /etc/network/interfaces entry for wired:
    auto eth0
    iface eth0 inet static
    address 192.168.10.1
    netmask 255.255.255.0
    pointopoint 192.168.10.2
    
  • Example Pi /etc/network/interfaces entry:
    auto eth0
    iface eth0 inet static
    address 192.168.10.2
    netmask 255.255.255.0
    pointopoint 192.168.10.1
    
  • After updating, restart networking on both:
    • Ubuntu: sudo systemctl restart networking
    • Pi: sudo /etc/init.d/networking restart
  • Confirm IPs stick with ip a — you should see the static addresses assigned to the target NICs.
3. Check Route Tables

Point-to-point networks rely on explicit routes. Let’s verify they exist:

  • On Ubuntu, run route -n — you should see a line like this (for eth0):
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.10.2    0.0.0.0         255.255.255.255 UH    0      0        0 eth0
    
  • On the Pi, the route table should have a matching entry pointing to your Ubuntu’s IP.
  • If no route exists, add it manually:
    • Ubuntu: sudo route add -host 192.168.10.2 dev eth0
    • Pi: sudo route add -host 192.168.10.1 dev eth0
4. Firewall Rules Are Almost Always the Culprit

This is the most overlooked step! Let’s rule it out:

  • Ubuntu 16.04 uses ufw by default. Check its status with sudo ufw status. If active, allow traffic from your point-to-point subnet:
    sudo ufw allow from 192.168.10.0/24 to any port 22
    sudo ufw allow from 192.168.10.0/24 to any proto icmp
    
  • On the Pi, check sudo ufw status too. If it’s enabled, add the same rules (swap the subnet if needed, but it should be the same).
  • For quick testing, temporarily disable firewalls on both: sudo ufw disable. If SSH works after this, you know the issue was a missing rule. Don’t forget to re-enable firewalls once you fix the rules!
5. Test Basic Connectivity First

Before jumping to SSH, confirm the network layer works:

  • On Ubuntu, ping the Pi’s IP: ping 192.168.10.2. If you get responses, the network is up, and the problem is likely with SSH itself.
  • If ping fails, try pinging from the Pi to Ubuntu: ping 192.168.10.1. If neither works, double-check your NIC configs or try swapping cables/ports.
6. Confirm SSH Service is Running on the Pi

If pings work but SSH fails, make sure the Pi’s SSH service is active:

  • On the Pi, run sudo systemctl status ssh. If it’s inactive, start it with sudo systemctl start ssh and set it to auto-start on boot: sudo systemctl enable ssh.
  • Check the SSH config file /etc/ssh/sshd_config to ensure:
    • PasswordAuthentication yes (if you’re using password login)
    • PermitRootLogin yes (if you’re logging in as root — though this isn’t recommended, it’s useful for testing)
  • Restart SSH after config changes: sudo systemctl restart ssh

Give these steps a try, and let me know which one fixes the issue!

内容的提问来源于stack exchange,提问作者Justin Ting

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:40:47