环境:
硬件:RASPBERRY PI 3B+
软件:2017-09-07-raspbian-stretch-lite
步骤:
在配置静态IP 的时候被网络上互相转发的文章忽悠了,浪费了很多时间。
最后还是看看/etc/network/interfaces的注释,一切是那么的简单。
设置方法如下:
有线网络静态IP
注意:在最新的raspbian 系统(2017-08-16-raspbian-stretch-lite)中,有线网卡的名字不在是eth0,而是enx三个字母开头加上网卡地址
先用ifconfig 查看网卡地址,加下enx开头的网卡名字, 然后修改/etc/dhcpcd.conf文件
ifconfig
...
enxb827eba16fff: flag=xxxx
...
sudo echo "interface enxb827eba16fff">>/etc/dhcpcd.conf
sudo echo "static ip_address=192.168.16.2/24"
sudo echo "static routers=192.168.16.1"
sudo echo "static domain_name_servers=8.8.8.8"
无线网卡静态IP
无线网卡配置和有线网卡的配置方式一样,都是修改dhcpcd.conf 文件
sudo echo "interface wlan0">>/etc/dhcpcd.conf
sudo echo "static ip_address=192.168.16.2/24">>/etc/dhcpcd.conf
sudo echo "static routers=192.168.16.1">>/etc/dhcpcd.conf
sudo echo "static domain_name_servers=8.8.8.8">>/etc/dhcpcd.conf
无线网卡可以设定链接的无线网络SSID, 密码。这样开机就可以自动连上了
sudo echo "network={">>/etc/wpa_supplicant/wpa_supplicant.conf
sudo echo " ssid=\"无线网络名\"">>/etc/wpa_supplicant/wpa_supplicant.conf
sudo echo " psk=\"密码\"">>/etc/wpa_supplicant/wpa_supplicant.conf
sudo echo "}">>/etc/wpa_supplicant/wpa_supplicant.conf
网友评论