###一 、在樹莓派端設置
首先,以root權限編輯 /etc/network/interfaces
sudo nano /etc/network/interfaces
將文件修改並保存
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static #靜態方式
address 192.168.1.120 #要設置的靜態IP,以路由器規則爲準
netmask 255.255.255.0 #子網掩碼
gateway 192.168.1.1 #網關地址
子網掩碼、網關設置可以在win下的cmd命令行界面中輸入ipconfig獲取
###二 、在路由器端設置
- 首先,登陸路由器管理界面,一般爲192.168.1.1 、192.168.0.1 、192.168.2.1,可以通過路由器的說明書來獲取,也可通過第一種方法來查看默認網關,一般默認網關即爲路由器ip。
- 找到IP與MAC綁定功能(各個路由器功能名稱大同小異)
- 將ip與樹莓派的MAC綁定即可