树莓派-树莓派设置静态IP和DNS

  • 需要编辑/etc/dhcpcd.conf文件
1
sudo nano /etc/dhcpcd.conf
  • 修改如下
1
2
3
4
interface eth0
static ip_address=192.168.1.177/24
static routers=192.168.1.1
static domain_name_servers=114.114.114.114 8.8.8.8 8.8.4.4
  • 重启网络服务
1
2
3
4
5
# 重启所有网络接口
sudo service networking restart

#
sudo ifconfig eth0 down && sudo ifconfig eth0 up
  • 查看当前网络信息
1
ifconfig -a

树莓派-树莓派设置静态IP和DNS
https://dnacore.github.io/post/59a43f15-c49b-404a-80a2-0a04e3819dc7.html
作者
DNACore
发布于
2019年10月17日
更新于
2023年7月4日
许可协议