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

network={
    ssid="SSID"
    psk="Your_wifi_password"
}

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=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

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 *