树莓派4B更改静态IP

更改以太网口静态Ip

先看一下环境:

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.75-v8+ #1270 SMP PREEMPT Tue Sep 24 18:59:17 BST 2019 aarch64 GNU/Linux 
#采用的树莓派原系统

看到网上的说法是编辑/etc/network/intnterfaces。但我实际擦看这个文件的时候里面提示因该去修改另外一个文件

pi@raspberrypi:~ $ cat /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

所以我去编辑了/etc/dhcpcd.conf

pi@raspberrypi:~ $ sudo nano /etc/dhcpcd.conf

  GNU nano 3.2                                                                                             /etc/dhcpcd.conf                                                                                                     


# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1
interface eht0
static ip_address=192.168.0.251/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8

按照上面#号的示范内容去改了自己需要的IP地址。
保存文件
然后执行重启

sodu reboot

到此ip就被设置成想要的静态IP地址

你可能感兴趣的:(树莓派)