Whenever you remote the Raspberry Pi using your network the router assigns random IP address, this may become difficult to access your Raspberry Pi. So to overcome this we need to configure the Raspberry Pi to static ip address.
Now we need open our DHCP configuration file, to add in our static IP variables.
sudo nano /etc/dhcpcd.conf
Scroll down to the bottom of the file, and add the following lines Static IP address.
interface <Network_Interface>
static ip_address=<Static_IP>/24
static routers=<Router_IP>
static domain_name_servers=<Name_Server>
When that’s completed, save the file using CTRL+X, “Y” to overwrite file, and “Enter” to confirm.
This changes will take effect after we reboot or restart Network.
sudo systemctl enable dhcpcd.service
Reboot your Raspberry Pi
sudo shutdown -r now