設置樹莓派靜態ip,只需在 /etc/dhcpcd.conf下添加:
interfaceeth0
staticip_address=192.168.1.105/24
staticrouters=192.168.1.1
staticdomain_name_servers=8.8.8.8
interfacewlan0
staticip_address=192.168.1.106/24
staticrouters=192.168.1.1
staticdomain_name_servers=8.8.8.8
如果在/etc/network/interface中添加了如下內容會出現連不上外網的現象:
auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.105
netmask 255.255.255.0
gateway 192.168.1.1
那麼在 /etc/dhcpcd.conf會出現:
interfaceeth0
staticip_address=192.168.1.105/24
staticrouters=192.168.1.1
staticdomain_name_servers=
static domain_search=
將其修改爲如下內容,則聯網使用正常
interfaceeth0
staticip_address=192.168.1.105/24
staticrouters=192.168.1.1
staticdomain_name_servers=8.8.8.8
#static domain_search=