笔记本与树莓派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:
- 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.,eth0orwlan0) and confirm its status isUP(noDOWNor error messages). Do the same on the Pi with the same command.
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/24and the Pi to192.168.10.2/24. - Example Ubuntu
/etc/network/interfacesentry 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/interfacesentry: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
- Ubuntu:
- Confirm IPs stick with
ip a— you should see the static addresses assigned to the target NICs.
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 (foreth0):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
- Ubuntu:
This is the most overlooked step! Let’s rule it out:
- Ubuntu 16.04 uses
ufwby default. Check its status withsudo 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 statustoo. 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!
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.
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 withsudo systemctl start sshand set it to auto-start on boot:sudo systemctl enable ssh. - Check the SSH config file
/etc/ssh/sshd_configto 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

