Modify /etc/dhcpcd.conf which is the DHCP configuration file
add the following
vi /etc/dhcpcd.conf # Use vi to edit the file and add the following configuration items
# Specify the interface wlan0 interface wlan0
# Specify a static IP, /24 means the subnet mask is 255.255.255.0
static ip_address=192.168.1.20/24
# router/gateway IP address
static routers=192.168.1.1
# Manually customize the DNS server
static domain_name_servers=114.114.114.114
# After the modification is completed, press the esc key and enter
:wq to save.
Restarting the Raspberry Pi takes effect sudo reboot