How to configure a Raspberry Pi with a Static IP

sudo nano /etc/dhcpcd.conf

Scroll to the bottom of the file and add the following lines:

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

#Remove these and reboot to return to dynamic IP
interface eth0
static ip_address=192.168.11.101/24
static routers=192.168.11.1
static domain_name_servers=192.168.1.1

Save the file: Ctrl+O, then Enter
Exit the nano editor: Ctrl+X
Reboot the computer

sudo reboot

Notes:
The subnet mask is written in CIDR notation at the end of the static IP address.
‘static routers=’ is the default gateway
‘static domain_name_servers=’ can be followed by multiple IP addresses, with each address separated from the previous by a single space ‘ ‘.

Author: admin on January 19, 2017
Category: Raspberry Pi

Leave a Reply

Last articles