Skip to content

Instantly share code, notes, and snippets.

@YuxiUx
Last active May 11, 2018 23:35
Show Gist options
  • Save YuxiUx/c21f31dc5eefc8472800a1f333fd5f5b to your computer and use it in GitHub Desktop.
Save YuxiUx/c21f31dc5eefc8472800a1f333fd5f5b to your computer and use it in GitHub Desktop.
How to set static IP in Raspbian

Set static IP in Raspbian

It's work on all relases since 2016
Not edit /etc/network/interfaces !

Open /etc/dhcpcd.conf

sudo nano /etc/dhcpcd.conf 

Scroll to bottom of this file and add your config as is explained in example.

  • Interface values eth0 for lan(cable), wlan0 for wirless(wifi)
  • In ip_address you can write any ip you want. Make sure you add /24 at the end
  • Both routers (Gateway IP) and domain_name_server (DNS ip) in normal situation refer to IP of your router

Example configuration:

interface eth0

static ip_address=192.168.1.5/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

interface wlan0
#(...)

When you are done, press Ctrl+o to save file and Ctrl+X to exit nano. At the end reboot system and enjoy your new static IP. (After reboot you can check you ip using ifconfig)

@YuxiUx
Copy link
Author

YuxiUx commented May 11, 2018

On ssh double-check IP you set and reboot only if you absolutely sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment