How to set Static IP on Raspberry Pi 3. This is the latest 2017 tutorial about configuring static IP for Ethernet as well as Wifi interface on Raspberry Pi 3. You can choose from two methods in this tutorial in configuring a static IP for Ethernet and Wifi interface.
In this tutorial, I will set Ethernet IP as 192.168.2.200 and Wifi as 192.168.2.201
You can also watch the video tutorial
Let’s get started
Connect Raspberry Pi to the router using Ethernet cable and connect your computer on the same network.
First, we need to get some information about your network so run cmd
On Command prompt type ipconfig /all
From this image, my network is around 192.168.2.x
We need to take note of the default gateway and DNS servers
In this example we get:
- Default Gateway: 192.168.2.1
- DNS Servers: 192.168.2.1
On your computer, Open Putty and type in the address: rasberrypi.local and click open
Network information gathering
Once you have logged in, check your Raspberry pi network. Type this command:
ifconfig
The Raspberry Pi is on the same network 192.168.2.x
Let’s proceed to configure static IP Address. You can choose from the two method on doing that
Method 1: DHCPCD
Edit Network interface
sudo nano /etc/network/interfaces
Let it use the default configuration
auto eth0
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Edit the WPA Supplicant
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Paste this:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Your SSID Here"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="YourPresharedKeyHere"
}
Change the ssid with your wifi name and psk will be your wifi password. Save and exit.
Edit DHCPCD
sudo nano /etc/dhcpcd.conf
Enter this code below
interface eth0
static ip_address=192.168.2.200/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
interface wlan0
static ip_address=192.168.2.201/24
static routers=192.168.2.1
static domain_name_servers=192.168.2.1
Ensure both service are enabled
sudo systemctl enable dhcpcd
sudo systemctl enable networking
Reboot the system
sudo reboot
Login again and test your internet
sudo apt-get update
Method 2: NETWORK INTERFACE
Edit network interfaces
sudo nano /etc/network/interfaces
Paste this code:
auto eth0
iface eth0 inet static
address 192.168.2.200
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.2.201
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Edit the WPA Supplicant
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Paste this:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Your SSID Here"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="YourPresharedKeyHere"
}
Change the ssid with your wifi name and psk will be your wifi password. Save and exit.
Check DHCPCD
sudo nano /etc/dhcpcd.conf
You can leave your configuration, we will disable the service anyway
Disable DHCPCD
sudo systemctl disable dhcpcd
Only Networking will be used
sudo systemctl enable networking
Reboot the system
sudo reboot
Login again and test your internet
sudo apt-get update