Configuration file

In order to change the IP address of the Raspberry PI you have to find the configuration network file. It is located in /etc/network/interfaces. To edit this file you can use nano, the default editor available in the official Raspberry PI OS, Raspbian.

sudo nano /etc/network/interfaces  

From here, if you use an Ethernet cable you can modify the lines below “allow-hotplug eth0”

Static IP address

To change the IP address of the Raspberry PI with a static one (i.e, you have to know your netmask and gateway.

allow-hotplug eth0  
iface eth0 inet static  

Those IPs are fictives and need to be replaced by the one of your current configuration.

How to get the netmask and gateway ?

On Windows you can use the shortcut Win+R. Then you can type “cmd” and “ipconfig”. See the video

On Mac or Linux, open the terminal and type “ifconfig”.

Automatic IP address (DHCP)

To use the DHCP protocol (IP address are automatically delivered by the router or switch), you can just replace “static” or “manual” by “dhcp”. No need to specify the netmask and gateway because DHCP delivered them by definition.

allow-hotplug eth0  
iface eth0 inet dhcp  

And for the WIFI ?

You just need to replace “eth0” by “wlan0” and that’s it!

If you have any comments, please let me know in the comments!