ubuntu系統修改靜態IP的方法是在修改/etc/network/interfaces文件,而樹莓派此文件下有說明:
# interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d
稍微翻譯一下:注意這個文件和dhcpcd一起使用,要更改靜態IP的話要參照/etc/dhcpcd.conf 和 shell里輸man dhcpcd.conf查看手冊。
因此要改靜態IP就要更改/etc/dhcpcd.conf文件。
在此文件后面添加
interface wlan0 static ip_address=192.168.8.88/24 static routers=192.168.8.1 static domain_name_servers=192.168.8.1
wlan0是無線配置,想設置有線配置可以改成eth0(網卡用ifconfig來查詢)
ip_address是要配置的靜態IP,后面要加上/24,代表子網掩碼位數。表示32位的字碼掩碼前24位是1,即為(11111111,11111111,11111111,00000000),換算成十進制就是255.255.255.0
routers是路由地址
domain_name_servers是DNS,填路由地址就行了
最后在shell中輸入命令
sudo reboot now
重啟,登錄路由器后台,看到已經IP已經改變
over
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
如果想在燒錄系統時就更改為靜態IP
在把TF插入linux環境的電腦中,然后切換至掛載的磁盤/etc/dhcpcd.conf目錄下
輸入
sudo chmod 666 dhcpcd.conf
使文件可寫,然后
gedit dhcpcd.conf
直接把靜態IP信息復制到dhcpcd.conf文件,按Ctrl+S保存