Setup a Raspberry Pi Static IP Address
In this tutorial, I use Raspbian operating system. How to setup a Raspberry Pi Static IP Address.
Recommended
- Raspberry Pi
- Micro SD Card
- Power Supply
- Ethernet Cord or WiFi dongle (The Pi 3 and 4 has WiFi inbuilt)
Step 1: we will first need to retrieve some information about your network
ip r | grep defaultStep 2: Retrieve the current DNS server and opening up the “resolv.conf” configuration file
sudo nano /etc/resolv.confSetting nameserver alternative DNS – such as 8.8.8.8 for Google, or 1.1.1.1 for Cloudflare.
Step 3: modify the way the Raspberry Pi handles the network.
sudo nano /etc/dhcpcd.confAdd lines as below:
interface <NETWORK>
static ip_address=<STATICIP>/24
static routers=<ROUTERIP>
static domain_name_servers=<DNSIP>
• NETWORK – your network connection type: eth0 (Ethernet) or wlan0 (wireless).
• STATIC_IP – the static IP address you want to set for the Raspberry Pi.
• ROUTER_IP – the gateway IP address for your router on the local network.
• DNS_IP – the DNS IP address (typically the same as your router’s gateway address).
Now save the file by pressing CTRL + X then Y followed by ENTER.
Step 4: Restarting the Raspberry Pi
sudo reboot
Test new static IP address.
hostname -I
Comments
Post a Comment