X

Setting up a static IP address or Wifi on Raspberry PI 2 B

Eth0 static IP address configuration

On the latest version of Raspbian (in my case, Raspbian GNU/Linux 8), you should not use /etc/network/interfaces to set up your networks.
All configuration has been offloaded to the dhcpcd client.

For a static IP address on the eth0 interface, you’ll need to edit file /etc/dhcpcd.conf

For a static IP address of 192.168.1.150, add the following lines at the end of the file (adjust the IP addresses to your own situation):

# Custom static IP address for eth0.
interface eth0
static ip_address=192.168.1.150/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
static domain_search=

WiFi configuration

Also on the latest version of Raspbian, if you use another user than the PI user to set up a WiFi network from the desktop, you will get an error about access to the dhcpcd.conf file.

This is due to the file’s group permissions:

4 -rw-rw-r-- 1 root netdev 1438 Feb 28 11:41 dhcpcd.conf

Solution #1: Add the user to the netdev group

Issue the command:

sudo adduser $USER netdev

Logout after doing this, and log in again. Now you should be able to access the configuration dialog.

Solution #2: Add the network manually

Add the following to the file  /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="My_Networks_SSID"
psk="mypassword"
key_mgmt=WPA-PSK
}

Replace the values between the double quotes with whatever value you need for your network.
Note that it also applies to WPA-PSK secured networks only, use a different value for key_mgmt if you use WEP or no security at all.

Eelco Ligtvoet: Dutch nerd
Related Post
Disqus Comments Loading...

This website uses cookies.