I would like to create static local IP addresses so I can ssh and network Pis easier. I've found some tutorials online for how to make static IP address such as for setting up a public server. Because I'm only networking Pis across a switch, I don't need the extra work of making them publicly accessible. What is the most minimalist way to create only a locally static IP address on raspbian? What range of addresses can I use?

  • While there are other methods,like manually configuring the pi wi a static address, the DHCP solution mentioned in two answers (so far) is really the best.
    – Tyson
    Mar 23, 2015 at 14:54

7 Answers 7


You need to set up a DHCP reservation on your router. DHCP is the protocol used by routers to dynamically assign IP addresses to devices on the network. You can tell the router the MAC address of your Raspberry Pi and the IP address you want it to have, and it will always reserve this address for the Pi, even if it's disconnected for a time. This doesn't require any configuration on the Pi's end.

Routers have all kinds of different interfaces, but I am pretty confident that this is a feature all will have. I can't give a guide for all routers, but here is a tutorial that might help, and Googling around with the name/model of your router will probably turn up more specific results.

As far as I know, you can use just about any IP address in the private network range. I would go for anything with 192.168.1.X where X is from 2 to 255. is usually reserved for the router itself. If you want more info see the Wikipedia article about Reserved IP addresses.


Add the addresses to /etc/hosts on each machine.

Something like  machine_1  machine_2

The 192.168.X.X addresses are non routeable so are quite safe to use.

  • Is the 192.168 part unique to each router?
    – twinlakes
    Mar 22, 2015 at 16:22
  • Doesn't this just map dynamic ip to a hostname, so restarting machine_1 could make this not work?
    – twinlakes
    Mar 22, 2015 at 18:27
  • I think you will want to do this in addition to DHCP reservation. This just tells the client machines how to interpret the names of the Pis as IPs. Most routers use 192.168.X.X, some (like Apple routers) use 10.0.X.X.
    – krs013
    Mar 23, 2015 at 20:48

I believe this command is the true easiest way to set a static IP address

$ sudo ifconfig eth0 your_ip_addr

source: https://www.linux.com/component/content/article/9400?format=pdf


STEP 1 Find your default gateway IP by

$ route -ne

Under the Gateway column, you will find your Default Gateway IP ( in my case) for each interface . Note it down .

STEP 2 Find out the IP addresses of your domain name servers by

$ cat /etc/resolv.conf 

note down the IP's displayed ( simply copy numbers n text (may be ) after nameserver , ( there will be one / many , just copy them

Generated by resolvconf

nameserver (copy )

nameserver XXX.xx.XX.xx:ff (copy XXX.xx.XX.xx:ff )

nameserver xx.xx.xx.xx (copy xx.xx.xx.xx)

for me i got only ' '

STEP 3 Editting dhcpdc.conf

$ sudo nano /etc/dhcpcd.conf 

you will find few lines with # in the beginning , scroll to the end and add these lines


interface eth0
static ip_address=
#your desired static IP (eth0)

interface wlan0 static ip_address= #your desired static IP (wlan0)

static routers= #default gateway IP address (from STEP 1)

static domain_name_servers= XXX.xx.XX.xx:ff xx.xx.xx.xx #IP’s found in the /etc/resolv.conf file,(from STEP 2) Seperate each IP with a single space.

Save the changes made
Ctrl-X and Y


$ sudo reboot 


check that everything is working correctly lets ping Google

 sudo ping www.google.com 

As others have mentioned, one way to do this is to configure it at the router, and assign a static address that way.

Alternatively, ssh into the pi and set the appropriate settings in your /etc/network/interfaces file. Before you begin you can examine the existing settings by running cat /etc/network/interfaces.

Here's pretty step by step tutorial for how to customize this config for a static ip.

One other thing to be mindful of-- set your static IP to something not already taken, I.E. not your gateway or another computer or you'll run into trouble. It is generally easier to find unallocated addresses in the IP range on the higher end of the spectrum.


Also You can create network interface alias:

iface eth0:1 inet static

I believe what OP has marked answered is correct only for temporarily setting it. It will reset on reboot?

The way to do it is to

    sudo cp /etc/network/interfaces /etc/network/interfaces.backup
    sudo nano /etc/network/interfaces

In the nano editor file, ensure you enter the following:

    #This is a static IP configuration
    auto eth0
    iface eth0 inet static

    #Your static IP based on your router config
    address 192.168.1.xx

    #Leave the netmask as usual

    #Your router IP
    gateway 192.168.1.x 
    auto lo
    iface lo inet loopback

Make sure you save by CTRL+O to writeout and save.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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