当身边没有路由时,想要电脑远程连接树莓派,有两种方法:除了电脑共享网络给树莓派的方法,还可以给树莓派配置eth0静态IP,方法如下:
1 打开如下配置文件
sudo nano /etc/network/interfaces2 注释下面语句
#iface eth0 inet manual
3 在其后增加语句:
auto eth0 allow-hotplug eth0 iface eth0 inet static address 10.10.1.100 #静态IP netmask 255.255.255.0 #子网掩码 gateway 10.10.1.1 #网关
4 重启服务
sudo /etc/init.d/networking restart
5 验证是否配置成功,终端输入命令查看
ip add
若 eh0后出现10.10.1.100 IP,则配置正确
注:1 步骤3中#注释语句要删掉,不然会配置失败!
2 电脑端设置同一网段10.10.1.X,且两者都通过有线方式连接同一路由时,也可以在此网段内通信。