树莓派设置静态IP地址

首先,查看当前使用的网卡:

 可见使用的是无线网卡wlan0,IP为192.168.2.218

方法一:

命令行操作:

sudo nano /etc/dhcpcd.conf

在/etc/dhcpcd.conf文件底部添加如下代码:

interface wlan0  #网卡名
inform 192.168.2.218/24    #树莓派IP
static routers=192.168.2.1  #路由器IP
static domain_name_servers=192.168.2.1  #DNS,这里也是路由器IP

如果是有线网卡,则:

interface eth0
static ip_address=192.168.2.219/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1

本地网卡 + 无线网卡 IP 不可设置一样,否则冲突。然后 sudo reboot 重启系统。

方法二:

用VNC连接,进入图形界面操作。

进去后,右键WIFI图标,选择“Wireless & Wired Network Settings”,在选择“interface”-->"wlan0",按下图填:

 其实和上面一种方法殊途同归,也是修改同一个配置文件。

 

 

参考链接:

1. https://www.jianshu.com/p/f9cb0f85a4e6

2. https://www.jianshu.com/p/308fb22a7dab

posted @ 2019-12-29 15:46  Rogn  阅读(13583)  评论(0编辑  收藏  举报