How to set static IP address in Raspbian

I assume that Raspbian has been assigned an IP address automatically by your home wireless router using DHCP. To set a static IP address for it:

  • Run ifconfig. Note the interface (say eth0) and the values of the inet addr, Bcast and Mask entries.

  • Run netstat -nr. Note down the values of the Gateway and Destination entries.

  • Open the /etc/dhcpcd.conf file in an editor.

  • Find the commented lines starting with “Example static IP configuration”. Uncomment the lines concerned with interface, ip_address and router and fill in your details there. For example:

interface eth0
static ip_address=192.168.0.99/24
static routers=192.168.0.1
  • You will also need to set the DNS servers manually, as described here.

  • Reboot the system and it should have the static IP address you assigned.

Tried with: Raspbian 9

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.