banner



How to set a static IP address on a Raspberry Pi

Raspberry Pi Zero Source: Windows Central

The Raspberry Pi continues to exist i of the most impressive computers on the planet. Not for its ability, but for the possibilities. This thing can exist programmed with a mindboggling number of purposes, from modest servers and NAS to decision-making your domicile automation or even just a small-scale Linux figurer to learn some new It skills.

Whatever you want to use information technology for, it's a pretty solid bet that you'll need a static IP for it. Unless you lot're using something like the Raspberry Pi 400 hooked up to a display, you're probable using it headless. That is, without a GUI. In the case of the Raspberry Pi Zero, this is even more probable.

Setting a static IP for your Pi is really easy, and doesn't have to involve your home router which sometimes can mess information technology up anyway. Case in bespeak, the last Raspberry Pi I set up up on my home network I assigned a static IP in the router settings, and information technology just sort of forgot about it and assigned a totally different IP to my ad blocker then it didn't actually work properly. That's why you should follow these steps and fix it up on the Pi itself for the all-time results.

Setting up your Raspberry Pi

Raspberry Pi Source: Windows Central

This guide assumes that your Raspberry Pi is already prepare up and yous've flashed it with the Raspberry Pi OS already. If you haven't and need a helping hand, we accept a guide on setting up a headless Raspberry Pi using aught but your Windows PC.

Before you lot can set a static IP for your Raspberry Pi you will need to know what IP address it'south currently on. At this point, the quickest method is probably to log into your router'south software and grab it there, particularly if you're doing a headless setup. You lot'll need the IP accost to connect over SSH and do the rest.

With the IP address in hand, open a terminal (WSL or PowerShell is fine), and connect with the post-obit command:

            ssh pi@YourIPaddress                      

Accept the fingerprint past typing yeah and striking enter. If this is the first kicking yous'll demand to log in with the default countersign, which is raspberry. It'south a skillful idea to change this, but for the purposes of what nosotros're doing hither yous don't need to and can just bear on with the next step.

How to prepare a static IP on your Raspberry Pi

To set the static IP properly you'll need a few things. The first is the electric current IP of the Pi which you've already got, the side by side is your router'due south gateway IP and the current DNS IP accost. Nosotros tin go these last two from the Raspberry Pi terminal.

Router gateway IP address

Enter this command into the terminal:

            ip r | grep default                      

Note downwards the offset IP accost given equally this is the i you desire.

Router DNS IP address

Over again in the terminal, enter this control:

            sudo nano resolv.conf                      

This will open a file in the nano text editor and the IP address you're looking for is immediately subsequently nameserver. Annotation this down and press Ctrl + X to close out.

Setting the static IP address

Raspberry Pi Static Ip Config Source: Windows Central

The final pace is to set the static IP address for your Raspberry Pi. It involves appending some details to the end of a configuration file. You must make certain you either use the IP accost already given to your Raspberry Pi or that you lot're using an accost that is currently vacant.

To begin, enter this command:

            sudo nano /etc/dhcpcd.conf                      

This volition open upward the dhcpcd.conf file in the nano text editor. Utilise your cursor keys to navigate all the way to the lesser.

Make sure not to change any of the existing items in this file, then at the bottom, you'll be entering a block of text following this template:

            interface NETWORKTYPE static ip_address=YOURSTATICIP/24 static routers=YOURROUTERIP static domain_name_servers=YOURDNSIP                      

Yous'll replace the terms in capitals with the following:

  • NETWORKTYPE — Blazon either eth0 for ethernet or wlan0 for wireless.
  • YOURSTATICIP — Whatsoever static IP you desire to assign to the Raspberry Pi.
  • YOURROUTERIP — The gateway IP accost acquired above.
  • YOURDNSIP — The DNS IP address acquired above.

When finished you'll end up with something that looks a bit like this:

            interface wlan0 static ip_address=192.168.86.250/24 static routers=192.168.86.one static domain_name_servers=192.168.86.1                      

Now, printing Ctrl + X followed by Y to close and save the file. You'll need to reboot the Pi for the changes to take outcome, which yous can practise with the sudo reboot command.

Give information technology a minute to reboot, reconnect over SSH, and and then use the hostname -I control to confirm the IP address matches what you set above. It should lucifer, and now your Raspberry Pi should retain this IP whatever fourth dimension it boots. Ensure you don't assign annihilation to this IP address either manually or through your router settings, and y'all should exist practiced to go!

Source: https://www.windowscentral.com/how-set-static-ip-address-raspberry-pi

Posted by: haleycouldic1973.blogspot.com

0 Response to "How to set a static IP address on a Raspberry Pi"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel