Right way to connect to a wireless network and assign a static IP address in Raspbian

Connect to a wireless network

Add these code to /etc/wpa_supplicant/wpa_supplicant.conf


Then ifdown and then ifup your wireless interface.
Raspbian should connect to the network and get an IP address by dhcpcd automatically.

Set static IP address for an interface

NEVER modify /etc/network/interfaces again.

Add these to /etc/dhcpcd.conf

interface eth0
static ip_address=
static routers=
static domain_name_servers=

Replace eth0 and the addresses as what you want.

ref: 1 2

Leave a Reply

Your email address will not be published. Required fields are marked *