Navigation Menu+

Giving the Raspberry Pi a static IP address

Introduction

Ever had to run something on the Pi when you did not have access to an active network or at a time when you just simply wanted to connect to it directly. Setting a static IP address is the way to go for such a situation.

There are two ways to get this done, the right way and the hack (of sorts):

  1. Editing the interfaces file (the right way)
  2. Editing cmdline.txt (the hack)

Which method you choose depends on a number of factors

  1. Can you currently access the Pi over a network? If yes, then edit the interfaces file. If not go to the next point.
  2. Are you running windows? If yes, sorry bro the hack is your best bet for now. If No, then you can edit the interfaces file by mounting the SD/microSD card and editing the interfaces file

Editing the Interfaces file

On the Raspberry Pi

  • Open LXTerminal and type

sudo nano /etc/network/interfaces

  • Change iface eth0 inet dhcp to

iface eth0 inet static

  • Now we set the actual data (you can get away with just entering the address and gateway)

address x.x.x.x

netmask x.x.x.x

network x.x.x.x

broadcast x.x.x.x

gateway x.x.x.x

 

Editing CMDLINE.txt

Ah the casual windows user, I see.

Just plug in the SD/microSD card and open the cmdline.txt file and append to end of the file

ip=x.x.x.x

Source:

In A Nut Shell…Direct Network Connection

Submit a Comment

Your email address will not be published. Required fields are marked *