Skip to content
Step by Step Internet 🌐 Guides for learning to surf the Net

How to change the IP address of my Raspberry Pi without errors like an expert? Step by step guide

Default, every time we start a Raspberry Pi the IP address changes. That could create a problem, as in most cases we do not use it as a PC for ordinary functions, but dedicated to certain applications.

When trying to connect remotely from another device to perform a task, share a file, mount a web server or authorize an application, it is practically essential to have a static IP address, being able to enter more credentials without fear of failure.

We ourselves are going to change the dynamic address and create the static IP as experts, following recommendations in this article. But before doing the steps, it is convenient know some basic concepts so that we understand what we are doing and not be unnecessarily confused.

What should I keep in mind before modifying the IP address of my Raspberry Pi?

As you know, the Raspberry Pi operating system is configured by default to connect via DHCP. This causes that every time every time it starts, the IP changes. But, if you want to change the IP address or assign a static one to your single board computer, you must bear in mind that the procedure must be carried out with great care and following the corresponding steps.

Because making a mistake or not gathering the minimum necessary knowledge will prevent the correct configuration of the mini computer, the connection with other equipment and access to the Internet. Equally, you should know the advantages and disadvantages of changing the IP address. After analyzing these details, you will be able to configure the changes to the card, especially if the project you are going to execute requires it.

To access whenever you turn on the Raspberry or if you have to log in remotely with the same address. It is important in this case to know that it is not the same to move the address of the computer on a local network in which devices are paired on the same IP address as on a public Internet address where they constantly change. To do the procedure of changing the IP address, You must have an internet connection, either by Wifi or network cable to know the DNS and give them the corresponding value.

Everything points to what it is recommended to use the wired connection above wireless, as it generates better performance and fewer problems when establishing communication. Having these aspects clear, it is convenient to know the differences that the two types of IP addresses have and what are the steps that must be taken to carry out the configuration without failing in the attempt.

Dynamic IP vs Static IP What are the differences and when is it more convenient to use one or the other?

First of all, we must remember that an IP address is a unique number that is assigned to every device on a network and that allows communication with other teams. Now, let’s talk about dynamic IP addresses. These are the ones assigned by internet providers and change from time to time. The reasons are several, on the one hand changes in the network or when the device that sends the connection restarts.

This type of IP has its advantages, such as preventing cyber attacks and cannot be easily traced. They are free and, in case of being banned, when changing the IP you have a second chance. For their part, static IPs never change and are the same to connect certain equipment.

In most cases they are paid and are used, among others, by FTP servers, databases or web pages. Some of the advantages to consider is that they offer stable connections and higher speed, against the poor security online. Definitely, each of the types of IP addresses has its advantages. The decision of which one to use depends on the purpose of the connection. In the case at hand, it is better to have a static address in most cases.

Learn step by step how to change the IP address of your Raspberry Pi miniature computer

The steps that follow will allow us to have our static connection to make the best use of our Raspberry Pi card:

Check network card

This is the first step, let’s see the name of the network card and verify which IP is enabled.

To achieve this, we enter the following command:

  • ip link

Then will show us the details of each of the cards.

Ethernet chip in Raspberry computers

Configure ETH

In the previous image, we observe the “Interface eth0”, which we must configure by placing a command line in the terminal to access the configuration file of the network card.

What we need to add is the following:

  • sudo nano /etc/network/interfaces

After let’s enter this command, we are going to modify it.

IP configuration code in Raspberry

When you enter the above command, several expressions will appear with some numbers next to them, these are “Address”, “netmask”, “network”, “broadcast” and “gateway”.

We indicate what you must put in each of the sections of this code:

  • Address: goes the new address that you are going to place your Raspberry.
  • Netmask: refers to the mask of that IP address.
  • Network: refers to the network that the IP address is part of.
  • Broadcast: is the broadcast address.
  • Gateway: is the default gateway.

Restart the network

Once all the data is entered, the device must be rebooted for the entered changes to have the desired effect:

  • sudo /etc/init.d/networking restart

Code to configure IP on Raspberry Pi

If we apply the command and the changes are not saved, we can try this other one:

  • sudo ifconfig eth0 down

In the end, we will see that the new address that we have created and saved is already on our device and ready to be used. With these steps, we have learned the correct way to configure our static IP and thus be able to use our mini computer as a server for the specific task we want to perform, without fear that at the time of connecting our address has changed.