When you have your RaspberryPi on the network it is a good idea to give it a static IP address so that it will have a constant address for SSH, VNC, Media, Port Forwarding, etc. The first step is to come up with an address that isn’t already being used on your network. For me I started my RaspberryPi’s IP addresses at 192.168.100 since I know I won’t have that many computers on my network. Each time I get a new Pi I just increment the IP address from there.
Setting the IP address is easy but you have to check a few things on your router to make sure you are giving it the information it is looking for.
I started with opening the interfaces file with:
pi@raspberrypi ~ $ sudo nano /etc/network/interfaces |
once there locate the following line and comment it out with a “#”
iface eth0 inet dhcp |
to
#iface eth0 inet dhcp |
scroll to the bottom and add the following lines:
iface eth0 inet static address 192.168.1.115 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 |
The address line is where you’d put the IP address you want and the remaining lines you get from the router. If you are not sure how to get this information, the values above have worked on a few different routers that I tested.
Save and exit the editor with:
Ctrl+X Y Enter |
Once done reboot with:
pi@raspberrypi ~ $ sudo reboot |
and when the Pi boots up next type:
pi@raspberrypi ~ $ ifconfig |
and check the IP address. If everything was done right you’ll be set with that address every time you reboot!
See you next time,
WeekendEngineer