I have followed (any one of hundreds) tutorial, and it does not work.

How do I set up networking/WiFi/static IP address on the Raspberry Pi?

(This is a Dorothy Dixer to hopefully catch the hundreds of similar questions.)


This tutorial describes how to setup networking using the default network manager dhcpcd included in Raspbian since 2015-05-05.
It applies to the Foundation releases of Raspbian Buster, Raspbian Stretch, Raspbian Jessie and the last Raspbian Wheezy.
Buster settings are identical to Stretch.

How to setup Raspbian Networking

If you are using an Ethernet connection with a router there should be no configuration required and it should work out of the box.

NOTE The Pi3/Pi Zero W inbuilt WiFi does not support 5GHz networks, and may not connect to Ch 12,13 on 2.4GHz networks until wireless regulatory domain is set.

WiFi on 5GHz enabled devices is disabled until wireless regulatory domain is set (Pi4B, Pi3B+, Pi3A+)

  • The domain can be set through Raspberry Pi Configuration (rc_gui), raspi-config or by setting country= to an appropriate ISO 3166 alpha2 country code in /etc/wpa_supplicant/wpa_supplicant.conf.

If you are using WiFi and the GUI set up by following the Foundation Guidelines

If you are using WiFi from the Command Line set up by following the Foundation Guidelines This is the only way to set up a network which does not broadcast SSID.

This can also be used to setup a 'Headless' system e.g. using a serial console cable, but it MUCH easier if you can borrow a monitor and keyboard for setup. See below for another possible method using an Ethernet cable to a PC.

Headless Raspbian WiFi Setup

Raspbian, since May 2016, checks the contents of the boot directory for a file called wpa_supplicant.conf, and will copy the file into /etc/wpa_supplicant, replacing any existing wpa_supplicant.conf file that may be there. The file in the boot directory is then removed. This can be used to enable headless setup, using the wpa_supplicant.conf settings detailed below. (You will probably want to enable ssh as well.)

What is my IP Address?

If you just want to know the IP Address your Pi is using enter hostname -I on the command line.


As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually.

Enter sudo raspi-config in the terminal, first select advanced options, then navigate to ssh, press Enter and select Enable or disable ssh server.

For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.

Networking Files

If you are running a recent Raspbian /etc/network/interfaces should be as below. If you have changed it PUT IT BACK. (Or on Stretch just delete it - it effectively does NOTHING.)

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

The file /etc/wpa_supplicant/wpa_supplicant.conf will be created/modified by the recommended setup methods, but can be setup by hand. Recent Raspbian have an option in raspi-config to enter SSID and Password. It should contain something like the following:-

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


If you need to connect to a private network (i.e. no broadcast SSID) include the line scan_ssid=1 inside network={⋯}.

NOTE If you want to connect to different networks (e.g. at work or home) you can include multiple network={⋯} entries.

If you have access to multiple networks and want to connect to a specific network, include the line priority=100 inside the network={⋯} entry.
You can select a different priority for each network, the highest priority accessible network will be selected; the default is 0.

There are many other options which can be used see man wpa_supplicant.conf.

Notes on obsolete Operating Systems

Jessie does not include the 10-wpa_supplicant hook to manage WiFi interfaces, so links to wpa_supplicant are needed. These settings are incompatible with Predictable Network Interface Names.

The /etc/network/interfaces used by Jessie should be:-

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

NOTE calling dhcp in /etc/network/interfaces will disable dhcpcd.

Predictable Network Interface Names

Stretch introduced1 predictable network interface names which have been used in other distributions for some time.

Network interfaces will have names formed from a prefix en — Ethernet or wl — wlan followed by x indicating MAC and the MAC e.g. enxb827eb123456 or wlx00c140123456. The onboard WiFi of the Pi4, Pi3 and PIZeroW which is connected over sdio will however use the name wlan0

This can be beneficial to those using multiple network interfaces, however for most Pi users, with a single Ethernet and WiFi interface will make little difference. The previous names eth0 and wlan0 can be restored if you pass net.ifnames=0 on the kernel command line in /boot/cmdline.txt.

There is an option in raspi-config to enable predictable network interface names.

1. For some incomprehensible reason the Foundation decided to "Disable predictable network interface names for Ethernet devices" only 3 weeks after introducing the long-awaited feature. There is an option under Advanced Options of raspi-config to toggle this setting.

Setup a Static IP Address

See separate answer Static IP Address

Advanced dhcpcd Configuration

Raspbian, by default, uses dhcpcd to manage network interfaces. This is automatic, and most users need do no more than specify the SSID and password for wireless networks.

It is possible to configure how dhcpcd works by entering options in /etc/dhcpcd.conf; see man dhcpcd.conf.There is a good article on dhcpcd at https://wiki.archlinux.org/index.php/dhcpcd

The following describe some of the more common configurations:-

Fallback profile

It is possible to configure a static profile within dhcpcd and fall back to it when DHCP lease fails. This is useful particularly for headless machines, where the static profile can be used as "recovery" profile to ensure that it is always possible to connect to the machine. The static profile is setup as any other Static IP Address

    # define static profile
    profile static_eth0
    static ip_address=⋯
    static routers=⋯
    static domain_name_servers=⋯

    # fallback to static profile on eth0
    interface eth0
    fallback static_eth0

Prevent dhcpcd from configuring an interface

This is often done to enable the Pi to act as an Access Point (which needs to be configured using other files), while allowing normal DHCP configuration on other interfaces.

Add denyinterfaces wlan0 to the end of the file (but above any other added interface lines).

Prevent dhcpcd from configuring a gateway on an interface

If you want an interface to not install any default routes (often used in conjunction with a static IP address) specify


Host Specific Configuration

dhcpcd can configure interfaces dependent on the host network. This uses the Address Resolution Protocol (ARP) to probe hosts based on MAC or IP address before attempting DHCP resolution.

    interface bge0

    # My specific network
    profile dd:ee:aa:dd:bb:ee
    static ip_address=

    # A generic network
    static ip_address=

You can speed up DHCP by disabling ARP probing if you are not using these features and have a simple network.


Use different wpa_supplicant files

It is possible to configure dhcpcd to use different wpa_supplicant.conf files for a specific wireless interface.

Create a file named wpa_supplicant-"$interface".conf in /etc/wpa_supplicant/ e.g. wpa_supplicant-wlan0.conf will only be used by wlan0

/etc/wpa_supplicant/wpa_supplicant.conf will be used for any other wireless interfaces.

Connecting a Computer to the Pi

Recent versions of Raspbian (which use dhcpcd) allow ssh to work over a link-local address and avahi (which is a zeroconf implementation) enables programs to discover hosts running on a local network.

This means you can plug the Pi into a Computer (with an Ethernet cable) or a local network router and connect without knowing the IP address.

You can easily connect from Linux and OS X with ssh pi@hostname.local (the default hostname is raspberrypi) This should work with popular GUI ssh programs. This is sometimes problematic with some versions of Windows and networks which use .local in a non-standard way. (See https://en.wikipedia.org/wiki/.local)

NOTE .local resolution does not always work e.g. in rsync. The following should resolve IP (and can be included in bash scripts)
RemotePi=$(getent hosts hostname.local | awk '{ print $1 }')

If your system does not have getent to query the hosts e.g. macOS you can use the following:-
RemotePi=$(arp -n hostname.local | awk '{x = $2; gsub(/[()]/, "", x); print x }')

If you have multiple Pi you need to make sure each Pi has a unique hostname.

You can use a crossover cable, but you don't need one (most modern interfaces automatically detect).

One drawback of direct connection is that the Pi will have no Internet access and the date will not be set. You can copy the date from the host by running ssh pi@hostname.local sudo date -s$(date -Ins) before connection.


This tutorial is about setting up a normal Raspbian installation to access the internet using the included software. It also covers connections to other computers on the same network.

It is primarily aimed at helping new users struggling to get their Pi (especially WiFi) working .

It does NOT cover:-

  • Other Network Managers.
  • Running advanced networking on the Pi (e.g. DHCP servers, Tunnelling, VPN, Access Point).
  • Use of ipv6 (although if you have an ipv6 network this should work).
  • Alternate networking setups. (There are many different ways of setting up networking.)
  • 2
    I got confused by the "this is NOT something you would type into the file". If I'm not mistaken, what Milliways means here is that you wouldn't replace the entire file with this bit of text. However, it's perfectly fine to add this bit at the end (modifying the parameters to your liking, of course). Also, the routers and domain_name_servers lines are optional if you don't want to set up routing through that interface. – Mark Dec 4 '15 at 18:34
  • 4
    So, now, to configure your ip address, you need to have the DHCP client installed and use its configuration to set a static ip?! It doesn't work if I want a DHCP server on my Raspbian! The DHCP client is run after the DHCP server launch, so the ip is not yet set, making the DHCP server (isc-dhcpd) complain. – Luc Stepniewski Dec 23 '15 at 10:31
  • 16
    Where is this officially documented? – Alastair McCormack Jan 16 '16 at 14:13
  • 6
    Where IS this documented? I mean, WTF. I have followed these directions as well as many others and cannot get connected. I can happily see and scan networks, but it will never connect or associate. I'm so cranky about this. – AaronJAnderson Feb 4 '16 at 1:09
  • 4
    @MikeD. See raspberrypi.org/blog/… – Milliways Aug 6 '16 at 6:34

Setup a Static IP Address

Questions about setting Static IP Address are among the most common on this site. There are very many tutorials (many wrong, obsolete or incomplete).


Before proceeding I feel obliged to state that setting up a static address is NOT recommended. Telecommunications Engineers do not do this. Static IP Addresses can be the bane of a Network Administrator's life. There are situations where Static IP Addresses are necessary e.g. if you are running a DHCP server, or running on an isolated network with no DHCP server.

If you are determined to proceed anyway you should make sure you get it right. Adapted from Foundation Network Tutorial

Find the Settings of your local Network

This is most easily done with the Pi itself, using DHCP, but can be done on any computer on your network, although the commands may differ on other systems.


ip -4 addr show | grep global

which should give an output like:

inet brd scope global eth0
inet brd scope global wlan0

The first address is the IP address of your Pi on the network, and the part after the slash is the network size. It is highly likely that yours will be a /24.

The second address is the brd (broadcast) address of the network.

Find the address of your router (or gateway)

ip route | grep default | awk '{print $3}'

Finally note down the address of your DNS server, which is often the same as your gateway.

cat /etc/resolv.conf

# Generated by resolvconf

Then follow ONE of the following methods. (There are other methods not documented here. These are the most common on Raspbian.) (In either method substitute the appropriate network interface name for eth0, wlan0 or predictable network interface names.)

If you want to find the interface names, even if not connected, run the following command ls /sys/class/net/

In either method you should choose IP addresses which are not in use; ideally outside the range used by your DHCP server, within the same sub-network.

dhcpcd method

Leave /etc/network/interfaces at its default (as above).

Edit /etc/dhcpcd.conf as follows:-

 Here is an example which configures a static address, routes and dns.
       interface eth0
       static ip_address=
       static routers=
       static domain_name_servers=

       interface wlan0
       static ip_address=
       static routers=
       static domain_name_servers=

ip_address is the address and size from the command above (or another unused address on the same network), routers is the address of your router (or gateway). domain_name_servers is the DNS address(es) from /etc/resolv.conf. (see man dhcpcd.conf)

There is a good article on dhcpcd at https://wiki.archlinux.org/index.php/dhcpcd The Fallback profile is an alternative to static IP

Network Interfaces method

NOTE This method is NOT recommended (and only works if you disable the DHCP client daemon), particularly if you plan to use both interfaces.

Configure a static network adddress on your Pi in /etc/network/interfaces

auto eth0
iface eth0 inet static

allow-hotplug wlan0
iface wlan0 inet static
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

address is the address from the command above (or another unused address on the same network), netmask corresponds to network size/24. gateway is the address of your router (or gateway).

You can also specify dns-nameservers, but this is generally not necessary. The broadcast is automatically derived from address and netmask and need not be specified. For more detail see https://wiki.debian.org/NetworkConfiguration

You can set either or both eth0, wlan0 or one of the predictable network interface names

Then disable the DHCP client daemon and switch to standard Debian networking:

sudo systemctl disable dhcpcd
sudo systemctl enable networking

Reboot for the changes to take effect:

sudo reboot
  • 1
    What are the pros and cons of these two methods you mention? – Elliott B Jun 24 '18 at 23:51
  • @ElliottB read the Disclaimer above. – Milliways Jun 25 '18 at 4:39
  • 1
    I did read that, I'm just wondering about the two methods dhcpcd vs networking. I want to see if a static IP lets it boot faster, because I see a 15s delay for dhcpcd in systemd-analyze. – Elliott B Jun 25 '18 at 4:42
  • I don't use either - this is only there because so many people try (for whatever reason - which eludes me) BUT get it wrong, because they don't understand networking. There is no simple answer because it depends on what else you are doing. NOTE setting a static IP is unlikely to have ANY impact on boot time, unless you have a very slow DHCP server. If you have questions you should ask a Question - this is not a discussion forum. – Milliways Jun 25 '18 at 5:11
  • I've added static domain_search=example.local to the dhcpcd.conf method. Feel free to revert/edit/contact me. – MadMike Sep 11 '18 at 9:57

For a static IP address on an Ethernet connection:

  1. sudo nano /etc/dhcpcd.conf
  2. Type in the following lines on the top of the file:

    interface eth0
    static ip_address=192.168.1.XX/24
    static routers=
    static domain_name_servers=
  3. sudo reboot

This needs to be done for the recent Jessie update. /etc/network/interfaces should be left alone. Open your browser and enter your router address ( for most) and check your home network to make sure the Raspberry Pi shows up as 'Static'.

  • 5
    If you are going to copy parts of the answer at least you should get it right. – Milliways Dec 15 '15 at 23:37
  • 2
    It probably did work in your case, but not in general because dhcpcd inferred the netmask, which it cannot for other address ranges. Read the man pages. – Milliways Dec 17 '15 at 0:58
  • 1
    You assert that /etc/network/interfaces should be left alone, but you do not say why. In fact, quite the opposite is true. See my answer below. – JayEye May 12 '16 at 23:10
  • 2
    If you want to restart networking services without reboot, make sure you have auto eth0 above iface eth0 inet manual line in your /etc/network/interface file. Restart network via sudo service networking restart command – Barmaley Nov 2 '16 at 4:21
  • 3
    This can be a copied answer but has everything you need to setup a static ip on raspberry, the accepted answer is unnecessarily long. – Pedro Lobito May 31 '17 at 3:57

Short and foolproof method how to do this with:

Raspbian Jessie & Stretch

This will set a fixed IP and enable the ssh daemon:

  • Open /boot/cmdline.txt and add ip= to the end of the line.
  • Create an empty file /boot/ssh
  • Boot your Raspberry Pi
  • On Linux start ssh pi@ the password is raspberry. Use Putty on Windows to connect via ssh.

I'm using to this to access my Raspbian Jessie and Stretch which boots without a attached monitor, with power and ethernet only. After accessing it with a ssh shell I can continue my setup.

After this treatment the Raspberry PI had two IPs: One from the fixed IP you specified and one from the dhcp-client running on the Raspberry Pi.

ifconfig will show you the fixed IP. Whereas the blue arrow-Icon on the top-right shows the dhcpd-IP.

  • 1
    Please do NOT suggest disabling IPv6. There are NO need for that. – Anders Sep 7 '17 at 21:25
  • Why would I need 2 IPs? – user42000 Oct 20 '17 at 14:04
  • @SiXandSeven8ths There is no need for 2 IPs. I have observed the behavior and am describing it here to minimize surprises. I would improve my answer, but hadn't time to do that. – MadMike Oct 20 '17 at 14:42
  • @MadMike I had observed that too, and it screwed things up for me, eventually I sorted it out but this is confusing. – user42000 Oct 20 '17 at 15:05
  • 1
    @SiXandSeven8ths I'm sorry to hear that. It worked fine for me. Also this was the only way to do without attaching any monitor and keyboard to the raspberry pi. so I figured it could be useful to someone else. – MadMike Oct 20 '17 at 15:08

First thing you should do is make your Raspberry pi's IP static. So that whenever you power up your Raspberry pi it should connect to your access point(Hotspot).

Connect to your Access point. Type ifconfig in raspberry pi's terminal and enter that IP address below, in my case it was

Start by editing the dhcpcd.conf file

sudo nano /etc/dhcpcd.conf

Scroll all the way to the bottom and add this lines at the end as per your connection (wired or wireless).

interface eth0

static ip_address=
static routers=
static domain_name_servers=

interface wlan0
static ip_address=
static routers=
static domain_name_servers=

Press Ctrl+x to save and reboot. Now power up your raspberry pi and it will automatically connect to your access point.

protected by Ghanima Jan 27 '16 at 12:23

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.