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

  Переглядів 6,354

Intelligent Gaming

Intelligent Gaming

6 місяців тому

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.
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.
github.com/angryip/ipscan#ang...
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.
www.chiark.greenend.org.uk/~s...
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 - / discord
Facebook - / intelligent-gaming-101...
Mastodon - mastodon.social/@Intelligentg...
Patreon - www.patreon.com/user?u=102737305
Reddit - / intelligentgaming2020
Twitter - / inspectorgecko

КОМЕНТАРІ: 28
@IntelligentGaming2020
@IntelligentGaming2020 6 місяців тому
Don't forget to like, share, and subscribe to the channel as this helps me with the UKposts algorithm.
@joeables5949
@joeables5949 Місяць тому
Thank you! Easy to follow, clear, concise, direct and saved me some grief. I only wish I would've found your video sooner. Thank you!
@IntelligentGaming2020
@IntelligentGaming2020 Місяць тому
No problem :)
@MdSiam-kw5ox
@MdSiam-kw5ox 6 місяців тому
Thanks for this useful guide. 👍
@IntelligentGaming2020
@IntelligentGaming2020 6 місяців тому
Happy to help :)
@bestplayer4187
@bestplayer4187 5 місяців тому
Thank you very much mate!
@IntelligentGaming2020
@IntelligentGaming2020 5 місяців тому
No problem :)
@JonnieF14
@JonnieF14 4 місяці тому
Thank you so much!
@IntelligentGaming2020
@IntelligentGaming2020 4 місяці тому
No problem :)
@RafaLousasYt
@RafaLousasYt 3 місяці тому
Thanks!!
@IntelligentGaming2020
@IntelligentGaming2020 3 місяці тому
No problem :)
@RJ-cu4cj
@RJ-cu4cj 5 місяців тому
I have spent 6 hours trying to get this POS RP4 to accept my password and it will not. Keep gettign Accesss denied
@IntelligentGaming2020
@IntelligentGaming2020 5 місяців тому
6 hours? just wipe it and start again.
@currentgroup-zm3bq
@currentgroup-zm3bq 2 місяці тому
i cannot get this to work with mine. nothing changes when i follow this video. Ive been trying for 2 days now and nothing will work
@IntelligentGaming2020
@IntelligentGaming2020 2 місяці тому
Define "nothing will work"?
@currentgroup-zm3bq
@currentgroup-zm3bq 2 місяці тому
all good i actually got it working thanks. Not sure why i could not get it to set a static ip. @@IntelligentGaming2020
@cjlowe1650
@cjlowe1650 3 місяці тому
my ifconfig says eth0 ! I used that instead of end0 and it did not work . went to 127. whatever. does it always have to be end0 or what ifconfig displays? Thanks.
@IntelligentGaming2020
@IntelligentGaming2020 3 місяці тому
What ifconfig states.
@bridevalley
@bridevalley 4 дні тому
@@IntelligentGaming2020 This got me too until I read your comment here. So thank you!
@dhananjaimvpai
@dhananjaimvpai 5 місяців тому
doesn't seem to work with wlan0 for some reason 😅
@dhananjaimvpai
@dhananjaimvpai 5 місяців тому
created a file at the same path replacing end0 with wlan0 and of course replacing the ips on reboot and ifconfig shows the IP as expected, but it is not connecting to the network! trying to connect again with sudo raspi-config > system options > wireless throws error message. deleting the file and rebooting fixes the connectivity issue but raspi gets a dynamic IP from the router. used to be easy as f. with dhcpd.conf, the new system is confusing as heck and the forums are not helpful either. I automate my setup with an ansible script and I do not want to run shell commands one by one when I can update a file 😅
@IntelligentGaming2020
@IntelligentGaming2020 5 місяців тому
Hmm, interesting I'll check it on mine.
@dhananjaimvpai
@dhananjaimvpai 5 місяців тому
@@IntelligentGaming2020 just to update, if you add the ssid and psk also in the interfaces.d/wlan0 file it connects and gets a static IP, but then the dns doesn't work 😅 finally just settled to running nmcli commands to set the static IP and the gateway and the dns..it seems it updates a file in /etc/NetworkManager/ or something within an .nmconnetion file. I think it had a toml syntax, but can't remember off the top of my head
@cjlowe1650
@cjlowe1650 3 місяці тому
Finally! Thanks
@IntelligentGaming2020
@IntelligentGaming2020 3 місяці тому
No problem :)
@zephyr3375
@zephyr3375 3 місяці тому
The file doesnt exist
@IntelligentGaming2020
@IntelligentGaming2020 3 місяці тому
You have to create it.
Learn Now: Step-by-Step Guide to Setting Up a Static IP on Raspberry Pi
7:06
IT Samurai Teacher
Переглядів 1,2 тис.
0% Respect Moments 😥
00:27
LE FOOT EN VIDÉO
Переглядів 35 млн
You're running Pi-Hole wrong! Setting up your own Recursive DNS Server!
18:02
How to Setup a Raspberry Pi LEARNING Desktop (Linux, Hacking, Coding)
31:31
How to Assign Static IP Address to Raspberry Pi!
5:21
NematicsLab
Переглядів 117 тис.
The ULTIMATE Raspberry Pi 5 NAS
32:14
Jeff Geerling
Переглядів 1,1 млн
Linux Crash Course - Connecting to Linux Servers via SSH
15:54
Learn Linux TV
Переглядів 42 тис.