If you don’t want the router to keep assigning a new IP to the pi every now and then, then set a static IP. Image Credit
How to do it
1: First, Check if a service is enabled:
BASH
sudo service dhcpcd status
Sign up for our newsletter!
1.1: If it is, you are good to go. If not, run the commands:
BASH
sudo service dhcpcd start
sudo systemctl enable dhcpcd
2: Run command:
BASH
sudo nano /etc/dhcpcd.conf
3: Uncomment (remove the #
that is at the beginning) the following lines:
CONFIG
interface eth0
static ip_address=192.168.0.4/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
3: Change the line static ip-address=192.168.0.4/24
to what you want your new static IP to be. static ip_address=
proceeds, /24
follows. It should look like this. NOTE: Your IP has to start with 192.168
for this to work:
CONFIG
static ip-address=[Your IP]/24
4: Press CTRL+ALT+X
5: Hit Y
6: Reboot:
BASH
sudo reboot
7: Now, on a Windows machine on the same network, open up Command Prompt and type the batch code. NOTE: THE -t
FLAG IS NOT REQUIRED:
WINDOWS BATCH
ping [YOUR PI'S NEW STATIC IP] -t
8: Now wait for a response to test if it’s working
[…] them. If it complains that a port is in use, try a different one. I strongly recommend you have a Static IP Address set up on the Pi. NOTE: IN ORDER TO MAKE THIS NETWORK-WIDE, YOU HAVE TO SET UP “ROUTER” […]