Computer NetworksNETWORKS

"How To Set Up a Static IP Address on a Headless Raspberry Pi – Step by Step Guide"

In this video I cover how to set up a static IP address on a headless Raspberry Pi running Raspberry Pi OS Bookworm or Buster.

Step 1. Enable SSH.

The first thing we need to do is enable SSH or secure shell within Raspberry Pi OS so we can communicate with the Raspberry Pi on the network.

https://www.raspberrypi.com/software/

The easiest way to do this is to enable it when you initially flash Raspberry Pi OS to your SD card using the Raspberry Pi Imager tool.

With the application running, first, click on the CHOOSE OS button, and select either the 32bit or 64bit version of Raspberry PI OS.

Next, choose your Storage option, which will typically be your SD card, and then click on the cog icon.

From here, you can enable SSH, as well as the credentials for connecting later.

Once done, it is simply a matter of clicking the WRITE button to install Raspberry Pi OS, inserting the SD card into the Raspberry Pi and then powering up.

Alternatively, if you have already flashed the OS to your SD card, you can also enable ssh by creating a blank file called ssh and placing this into the root of the file directory.

Step 2. Find The Raspberry Pi’s IP Address.

Once the Raspberry Pi is connected to a network, it is very likely that it will have been given an IP address from your router using DHCP, so we need to determine what IP address it has been given.

The easiest way to do that is to use an IP scanner.

https://github.com/angryip/ipscan#angry-ip-scanner

My recommendation would be the Angry IP Scanner as this is cross platform and works on Linux, Mac OS, and Windows.

But in either case, run your chosen IP scanner on your local network, and once the scan has finished, sort by hostname and find the IP address given to the Raspberry Pi.

I would also take a note of the router / gateway IP address as this will be needed later.

Step 3. Connect To Raspberry PI Using SSH.

Now that we have the IP address of the Raspberry Pi, we can connect to it using a SSH client.

https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

A common one that people use is Putty, however in my case I will be connecting to the Raspberry Pi through ssh using the Linux Terminal with the following command.

ssh pi@192.168.1.2

And providing the correct credentials to log on.

Step 4. Set Static IP Address.

Once connected, the final pieces of information we need are the Ethernet network interface name and subnet mask, which can both be found by running the following Terminal command.

ifconfig

This will present a lot of information, however for me the Ethernet network interface is labeled as end0, and the netmask or subnetmask is 255.255.255.0.

At this point, we have all the information we need to set up a static IP address, but the file your amend will vary depending on the version of Raspberry Pi OS installed.

For example, for installations running Raspberry Pi OS Bookworm, you need to create a new config file called end0.

Which can be done with the following Terminal command.

sudo nano /etc/network/interfaces.d/end0

Inside the file, specify the IP address you wish to set as static, the network range, subnet / netmask, and gateway that matches your network.

For example, for my network, it is the below.

allow-hotplug end0
iface end0 inet static
address 192.168.1.2
network 192.168.1.0
netmask 255.255.255.0
gateway 192.168.1.1

Alternatively, if you are running an older version of Raspberry Pi OS such as Buster, then you would create a dhcpcd.conf file instead.

Once again, you can do this with a single Terminal command.

sudo nano /etc/dhcpcd.conf

Only this time, the contents of the file, should look something like this.

Interface end0
static ip_address-192.168.1.2/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

Obviously adjust to your network configuration, but once you are happy with the settings, save the file with CTRL + X, and then Y.

So, the final thing we need to do is reboot the Raspberry Pi, so it picks up the static IP address, which can be done with the following command.

sudo reboot

#raspberrypi #bookworm #linux

Social Media Links

Discord – https://discord.gg/3SxGk3WG2D

Facebook – https://www.facebook.com/Intelligent-Gaming-101640054531594

Mastodon – https://mastodon.social/@Intelligentgaming

Patreon – https://www.patreon.com/user?u=102737305

Reddit – https://www.reddit.com/r/IntelligentGaming2020/

Twitter – https://twitter.com/inspectorgecko

source

ip address

Alice AUSTIN

Alice AUSTIN is studying Cisco Systems Engineering. He has passion with both hardware and software and writes articles and reviews for many IT websites.

One thought on “"How To Set Up a Static IP Address on a Headless Raspberry Pi – Step by Step Guide"

  • Don't forget to like, share, and subscribe to the channel as this helps me with the YouTube algorithm.

Comments are closed.