解決樹莓派無法ping通樹莓派的wlan0口問題
最近在樹莓派上安裝 HomeAssistant 以配置HomiKit,但是發現樹莓派的無線網絡卡能正常連線無線網路,但是從電腦上ping就是不通,而且在電腦上SSH連線樹莓派顯示“ Could not connect to ‘192.168.0.104’ (port 22): Connection failed. ”,但路由器可以ping通,經過摸索發現,原來是樹莓派的路由表有問題,導致外網無法連線樹莓派。以下是解決無法ping通樹莓派的wlan0口的方法。
首先將樹莓派用有線的方式連線到了路由器,然後通過這篇文章配置樹莓派的無線網絡卡:
配置完成後使用無線網絡卡連線無線網,這時在路由器上可以看到樹莓派使用無線方式連線了,但是如開題所說的ping就是不通,而且在電腦上SSH連線不上。
這時在樹莓派使用有線連線並登陸,在樹莓派路由表上新增這樣的一條路由就可以了:
sudo route add default gw 192.168.0.1#192.168.0.1是無線路由器的地址
這時在ping樹莓派就能Ping通了,而且也可以在電腦上SSH登陸樹莓派,問題解決。
ssh [email protected] Connecting to 192.168.0.104:22… Connection established. To escape to local shell, press 'Ctrl+Alt+]'. Linux raspberrypi 4.14.50-v7+ #1122 SMP Tue Jun 19 12:26:26 BST 2018 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Tue Sep 25 20:43:01 2018 from 192.168.0.106