You will need to make changes to the network configuration file. Here’s a step-by-step guide to set up a static IP address on your Raspberry Pi running Raspbian OS (now called Raspberry Pi OS):
Open a terminal:
– If you are using the desktop environment, click on the terminal icon in the top menu bar.
– If you are using the command line interface (CLI), you can access the terminal directly.
2. Update the package lists to ensure you have the latest packages:
sudo apt update
3. Upgrade the installed packages to the latest versions (optional but recommended):
sudo apt upgrade
4. Open the dhcpcd.conf file using a text editor (nano, for example):
sudo nano /etc/dhcpcd.conf
5. Scroll to the bottom of the file and look for the following lines related to setting static IP addresses:
Example static IP configuration:
#interface eth0
#static ip_address=192.168.1.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1
6. Uncomment the lines by removing the ‘#’ symbol at the beginning of each line and modify the values to fit your network. For example:
interface eth0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
– `static ip_address`: Set the static IP address you want to assign to your Raspberry Pi.
– `static routers`: Set the IP address of your router (default gateway).
– `static domain_name_servers`: Set the IP address of your DNS server (usually the same as the router’s IP address).
7. Save and exit the text editor:
– For nano, press `Ctrl + X`, then `Y`, and finally press `Enter`.
8. Restart the dhcpcd service to apply the changes:
sudo service dhcpcd restart
9. Verify that your Raspberry Pi has obtained the static IP address:
ip addr show eth0
The output should display the IP address you set in the previous steps.
10. Reboot the Raspberry Pi to ensure all changes take effect:
sudo reboot
Your Raspberry Pi should now have a static IP address configured, and it will use this IP address each time it connects to the network. Make sure to update any devices on your network (such as routers, other computers, or smart home devices) that depend on the IP address of the Raspberry Pi.
0 Comments