Introduction: Ultimate Raspberry Pi Configuration Guide

The Raspberry Pi is a great thing: it is real computer, it is cheap ($40), it can interface with electronics, talk to the web and has full HDMI support.

However it runs on Linux, which I have a love-hate relationship with. I love the idea of Linux, but when I start messing around the command line and downloading packages and installing things, I often get lost.

I've assembled bits and pieces from various online posts and guides into this Instructable, which is what I call the "Ultimate Raspberry Pi Configuration Guide".

What this Instructable does is to set up a wireless Raspberry Pi that allows you to:
  • ssh into from the Terminal window on the Mac (or equivalent on another machine).
  • run wirelessly with a static IP for each SD card.
  • automatically startup, no log in
  • set your the time zone
  • skip the GUI of the Raspberry Pi, which bogs things down and is unnecessary for most tasks
  • minimize any external monitor use, specifically never having to lug a monitor over to where the ethernet router lives
  • clone a "basic settings" SD card so that we can have as many base-level installations as we want.

Right now, I have 3 Raspberry Pis running in my closet, each with a different purpose: one runs 7 Twitterbots, one is a Git server and one is an experimentation device for electronics. I plan to add more. 

I wrote this Instructable for someone who has a secure home newtwork. You should have a router that can accept a direct ethernet cable. If you are working at an office, the network configuration settings I've outlined here might have to be adapted for your specific company's network/firewall.

Step 1: Gather Materials

We need the following:
  • The Raspberry Pi itself
  • A power supply with a micro USB cable to power the Pi. Get a 2A one if at all possible
  • An 4gb SD card. For most cases, there isn't a need for anything larger.
  • A USB wifi dongle. There are many of these that are Pi-compatible on the market
  • An ethernet cable to go into your home router
Not pictured, but needed: an HDMI monitor with an HDMI cable, a keyboard and some sort of ethernet router than lets you plug an ethernet cable directly into the back of it.

Step 2: Download Raspbian Wheezy

Unless you need special Linux capabilities, Raspbian/Wheezy is the recommended installation.

Download the package here: http://www.raspberrypi.org/downloads

Make sure you double-click the downloaded .zip so that you have a .dmg file. For the purposes of this Instructable, I leave the .img in my downloads folder.

Note: I'm using a Mac as my host computer, but most of these instructions can be adapted for other operating systems.

Step 3: Initialize SD Card Using Disk Utility

Use Disk Utility to initialize your SD card. It doesn't matter what the name of the card is.

What does matter is that the format is MS-DOS (FAT). Format the SD card. It will only take a few seconds.

Quit Disk Utility when you are done.

Step 4: Copy the Wheezy Image Onto Your SD Card

Open the Terminal application on the Mac, which will be in your Applications folder.

For those of you unfamiliar with using this app, Terminal provides a command-line for controlling the underlying Unix operating system on Max OS X.

Type in (then press enter):
diskutil list
This will list all your mounted drives. You will see something like the image above: a list of drives with different partitions on them. You want to find the information pertaining to your newly-formatted SD card. In my case it is /dev/disk1s1. This may be different on your computer.

Now, unmount the disk using the Terminal command:
sudo diskutil unmount /dev/disk1s1
The device /dev/disk1s1 is from my setup — yours may be different. Important: use the right device name on your system.

The preceding sudo command stands for superuser do. These are commands that can wreak havoc if misused, so will require your Admin password.

You'll be shown a message that your SD card has been unmounted. Its disk image will disappear from the desktop.

Here's where you want to pay close attention. We want to type in a command such as:
sudo dd bs=1m if=~/Downloads/2014-01-07-wheezy-raspbian.img of=/dev/rdisk1
Note that we are using the "raw device", which means that the name /dev/disk1s1 maps to  /dev/rdisk1. Make sure you specify the appropriate raw device, i.e. if your SD device info from diskutil list is /dev/disk3s1, use /dev/rdisk3 for the dd command. 

Also, the filename or path for your wheezy-raspbian.img might be different that the one listed here, so please change it accordingly. 

Terminal will ask you for your admin password since this was a sudo command. Then you will have to wait long awhile. There is no feedback that any copying is actually happening. This takes something like 30 or 45 minutes. Go have lunch.

Behind the scenes: what the dd command does is copy the disk image and do any necessary conversions.

Once the dd process is done, Terminal will show you how many bytes were transferred to the SD card (about 2.9 gb). Eject the new SD card, which will be now mounted on your computer and be titled something like boot.

Congratulations, you have a bootable SD card for your Raspberry Pi!



Step 5: Basic Pi Configuration

Put the SD card in your Raspberry Pi, connect the keyboard, connect it to your HDMI monitor and plug in the USB power. leave the wireless USB dongle disconnected.

You'll see a black screen with a bunch of text, which shows all sorts of configuration details that you don't need to worry about.

This will take you to a Raspberry Pi configuration screen. You'll see this only the first time. The options are:

1. Expand Filesystem: no need to do this — some may disagree on this point
2. Change User Password: up to you
3. Enable Boot to Desktop/Scratch: by default, this is set to console, which is what we want to keep
4. Internationalisation Options: set your timezone (if in the US, choose America, then find the correct city with your timezone)
5. Enable Camera: no (you can always change this later)
6. Add to Rastrack: no
7. Overclock: this is up to you, I usually choose Medium, which makes the Pi run a little bit faster at the expense of power and potential component damange
8. Advanced options: choose A4 SSH -- this will enable secure shell access, which means that you can control your Raspberry Pi from a remote computer (extremely useful)

Choose Finish and reboot

When you get to a prompt, enter:
sudo nano /etc/default/keyboard
change XKBLAYOUT to ="us" — assuming you are in the U.S., but you can set this to whatever the keyboard code is for your country. Here is a list of country codes from Wikipedia, use two-letter lowercase ones.

nano is a simple built-in editor. Type in ctrl-X and Y and overwrite to save the file.

Make these keyboard changes take effect by rebooting:
sudo reboot



Step 6: Setting Up Auto-login

Your Raspberry Pi will be without a keyboard and without a monitor and accessible only by ssh — at least that's the setup that I'd recommend using. For that reason, we want to set it up to automatically login.

After the reboot, at the command line, enter:
sudo nano /etc/inittab
now, scroll down to the line:
1:2345:respawn:/sbin/getty 115200 tty1

and comment it out by putting a '#' in front of it, such as:
#1:2345:respawn:/sbin/getty 115200 tty1

don't worry if the 115200 reads as 38400 or anything like that, we're just looking for the 1:2345 line

now add the line, beneath it:
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

Be super-careful to get the spaces exactly right.

Now:
sudo reboot
and the pi should automatically login.

Step 7: Download an IP Scanner Package

If you're like me, there is no computer monitor near the ethernet jack. There's ways to get your Raspberry Pi ethernet address through using commands like ipconfig and hook the Pi directly to a monitor. This technique bypasses the lugging the monitor around the room.

My preference is to use IP scanning software on my laptop to identify the local IP address of my Raspberry Pi.

My weapon of choice is Angry IP Scanner which is a cross-platform, donation-ware tool. It has been working great on my Mac.

A note about IP addresses — and this is a broad topic — but the Raspberry Pi will be assigned a local IP address, or one on your private network. It will be IP-addressable, just like a networked printer, but not able to be directly accessed outside of your network.

For most of us, these are a 24-bit block of IP addresses in the: 10.0.0.0 - 10.255.255.255 range.

Step 8: Determine the IP Address and Ssh Into It

Connect the hard ethernet jack from the router to your computer and plug in the Raspberry Pi.

In this case, the pi has been assigned to 10.0.1.25, as we can see by the scanner (you'll get an error if you try to ssh into the other ip addresses). With the scanner packages, make sure to scan in the range of 10.0.1.0 - 10.0.1.255.

What we want to do is to log into it via ssh and finish configuring it for a static and wireless IP address.

Open Terminal and type in.
ssh pi@10.0.1.25
You may have to say "yes" to an authentication screen, but eventually should be able to get in with your password (hint: the default password is raspberry).

Congratulations, now you can ssh into your Raspberry Pi from any laptop on your network.




Step 9: Run Package Updates

On the command line, type in:
sudo apt-get update
then type in
sudo apt-get upgrade
Both of these commands will give you a lot of gobbledygook. You will wait awhile. Be patient. These update package lists from the various repositories and updates them to get information on the newest versions of packages and their dependencies. 

when done:
sudo reboot
You'll have to relogin via ssh. Hopefully, the same ethernet address will work, but possibly not, in which case you'll want to use the IP scanner again.



Step 10: Clone the SD Card

This step is optional and should be used if you are making more than one Raspberry Pi SD card. It will save lots of time. Otherwise, skip to the next steps on IP configuration.

What we do have is a fully-working Raspberry Pi setup, with auto-login, custom passwords, correct time zone and keyboard settings. We want to clone this setup so that we can bypass the hassle of going through the set up for each SD card: auto-login, time zone, updates, etc.

Since the static IP addresses wired & wifi are unique for each card, we will just add these individually.

Remove the SD card from your Pi and put it back into your Mac.

Launch Terminal and type in:
diskutil list
You've seen this before but now we have some slight differences in the partition name for the SD card. We don't convert to the raw device name this time, just use /dev/disk1

Type in the dd command, like this:
sudo dd if=/dev/disk1 of=~/Desktop/pibootable.img
This will copy the SD card image onto your desktop. For making new RPI SD cards, you would copy this Image onto your a new SD Card instead of the Wheezy image. You would then be able to proceed directly to the IP configuration steps.

Step 11: Assigning a Static IP

At this point, you still don't have your wireless USB adapter plugged in. What we ultimately want is a static IP assigned for every SD card. This way, when we ssh into the Raspberry Pi, we always know which address to use. Also, there won't be any collisions or confusion on the network. 

In theory, you could have a two Raspberry Pis and 10 SD cards. The IP settings will be stored on the SD card itself.

Put the SD card back in your Raspberry Pi.

Connect it with the ethernet cable to your router. Leave the wi-fi dongle disconnected.

Use ssh to get back to logging into your Raspberry Pi, i.e.
ssh pi@10.0.1.25
(or whatever address your IP scanner shows)

Type in:
sudo nano /etc/network/interfaces
You'll see some various settings that look like the image here.

We want to replace the line: iface eth0 inet dhcp
with: iface eth0 inet static

and then specify the address, netmask, network, broadcast and gateway, like this:

iface eth0 inet static
address 10.0.1.64
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255
gateway 10.0.1.1

What this is doing is instead of using DHCP, which dynamically assigns IP addresses, it assigns a static one: in this case it is 10.0.1.64

I picked this one because it is well out-of range of the lower IP addresses, which my network will assign for laptops, printers, etc. You can use a different IP address, if you want. This is just one that I've chosen that is out of collision range.

Before you save these changes, keep a copy of the text of the original /etc/network/interfaces file. You can copy-and-paste this in a text file on your local computer.

note: this is the technique that works on my home network. It may not work on yours, though it has worked for others.

Cntl-X, Y and Return to save and overwrite the file.

Now:
sudo reboot
Fingers crossed. Wait for a few minutes and see if can ssh into this new IP:
ssh pi@10.0.1.64
If asked for the RSA fingerprint, say yes.

If you have troubles, you can use the IP scanner. Real trouble and you might have to do go back to the monitor.

Step 12: Adding Wi-fi Support

At this point, you have a cable running to your Raspberry Pi. If your wi-fi dongle conks out, you can always go back to the cable. The static IP number will always be the same.

Time to specify the same static IP number for wireless.

Type in:
sudo nano /etc/network/interfaces
You'll see your edited file, like the image here.

find the line:
allow-hotplug wlan0

above it, add:
auto wlan0

then below it add:
iface wlan0 inet static
        wpa-ssid "yournetworkname"
        wpa-psk "yournetworkpassword"
address 10.0.1.64
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255
gateway 10.0.1.1

for wpa-ssid, add your network name
for wpa-psk, add your network password

** Unplug the power from the Raspberry Pi. Plug in your wi-fi dongle. Unplug the cable. Now log in via ssh. 

Once again, this work on my network, which uses standard WPA security. If you have a hidden network or additional security, then you'll have to do a bit more research to get these settings right.


Step 13: Done + Troubleshooting Tips

You're done!

For multiple SD cards, you'll want to use different IP addresses. I use a label-maker and adhere the IP addresses to the back of the SD cards, so I never get confused.

You're off to the races! Have fun.

RSA Key Troubleshooting
If you ever get this dialog in the Mac Terminal Window, it's super-confusing.

What this means is that you've used this IP address for another SD card and now you're trying to use it for another one. It won't let you in.

On the Mac, you'll want to delete a file called known_hosts, which is in a hidden .ssh directory on in your User folder. 

More Troubleshooting
The wi-fi configuration with the Raspberry Pi is definitely the trickiest portion of it. This technique works reliably for my home network, as well as several others that I coached through. I'm by no means an expert, so if you get stuck, you'll have to do some creative sleuthing.

I hope this was helpful!
Scott Kildall

For more on Raspberry Pi code and other projects, you can find me here:
@kildall or www.kildall.com/blog

Comments

author
henryv26 made it! (author)2016-12-29

Fantastic guide, thanks for the effort you put into this. Can you recommend a procedure to assign a static IPV6 unique address to each SD Card Clone and then taking that IPV6 address and renaming the" hostname" to match IPV6 address using some kind of automated or scripted procedure

author
ThundrV made it! (author)2016-11-03

Amazing guide! Just used it to set up my R-Pi + Android SSH access.

author
engdar made it! (author)2016-10-14

Hello. Is it possible to set up the raspberry pi for the very first time without an Ethernet? Like a WIfI dongle?

author
pro1962 made it! (author)2015-11-08

hi all ,, i just got my new raspberry pi b ,, some thing happen i do not understand ,, it installs the os not a problem , but i do not do a thing , no passwords, or typing , startx , so when i boot up it just goes to the main screen ,, maybe you might tell me

author
scottkildall made it! (author)scottkildall2015-11-08

Hi, I'm not sure exactly what you are asking :)

What is the "main screen"? Did you use this configuration guide? Did you get a command prompt?

author
pro1962 made it! (author)pro19622015-11-09

hi mate ,, i just reformatted the sd card and put the noobs i got of raspberry pi site , i looked at the files, it has the winzip file in there ,, should that be there as well ??

author
pro1962 made it! (author)pro19622015-11-08

the first time it boot up with no command prompt ,, so i sent the person a email who i got it of what to do, he told me to format the card and down load it again ,, which i did . after the format i made Shaw the card was empty , got on the raspberry site and down loaded it again . this time still no command prompt. just goes to the main screen with the rasp berry on it menu , files scratch wolfarm . so i do not really know if it all set up at all. i open some files like tools ,, nothing in there , so i really do not know what its doing .

author
pro1962 made it! (author)pro19622015-11-08

hi and thanks ,, i did not get a command prompt , it just went to the screen with the raspberry on it

author
scottkildall made it! (author)scottkildall2015-11-08

sounds like there is some sort of OS install issue. Are you installing just like the Instructable or running off the package? If the former, I'd try the steps once again starting from the SD card formatting.

author
scottkildall made it! (author)scottkildall2015-11-08

**are you running off a pre-built package like Noobs?

author
MarkovKane made it! (author)2015-05-25

I typed the wif page on step 12 exactly like it is in your thing but using all my ip info, and it didn't work for me, and now all my wifi settings are lost.

author
nevyn.hira made it! (author)nevyn.hira2015-06-10

Also, be aware that wifi support is going to be dependent on your dongle. For a lot of hardware, the vendors don't supply support so it takes volunteers to add that support. Other times, that support does exist but not in a "plug'n'play" type fashion i.e. it may require manual compiling of modules (well outside of scope if this is your first time playing with Linux) or installation of a dkms package (this gets complex as well but no where near as complex as compiling your own).

Linux does support more hardware out of the box BUT it's often slower to get the support to make newer (and/or troublesome) hardware work.

author
joedix made it! (author)joedix2015-06-07

In step 12, after changes are made and before you pull the power, do this.
1. Press 'crtl + x' to close nano, 'y' for yes to save, and enter for same filename.
2.type 'sudo shutdown now -h' to shutdown and halt.
Now proceed with removal of the power....

author
PatrikAa made it! (author)2014-04-16

good guide. but I have a problem with Raspberry pi, when I use sudo apt-get install in LXTerminal I get the error E: Sub-process /usr/bin/dpkg returned an error code (1) Do you have any tips.

error code 1.JPG
author
scottkildall made it! (author)scottkildall2014-04-16

Hmmm....I'm not familiar with this error, but this post seems to cover some possibilities:
http://superuser.com/questions/600010/raspberry-pi-apt-get-upgrade-failed

Some things to check:
1. I'm not sure what sudo apt-get install is supposed to do. Try sudo apt-get update then sudo apt-get upgrade

2. Try: sudo apt-get clean

3. The post suggests that the SD Card could be damaged, maybe try a different one.

Beyond that, I'm not too sure — you can always ask in the Raspberry Pi forums to get some more seasoned Linux folks to jump in.

author
nevyn.hira made it! (author)nevyn.hira2015-06-10

It's down to 1 of 3 things (I think).

1. dpkg is broken because:
1.1 it has broken packages (dependencies not met?). For this run:

sudo apt-get install --fix-missing
1.2 Something has gone wrong while installing a package. Quick fix (hopefully this works):

sudo dpkg --configure -a

Otherwise, try to remove the offending package using:

sudo dpkg --purge [package name]
2. Something else is using dpkg. You can't run multiple copies of dpkg at the same time. either wait a while, or, if that doesn't work, reboot.

author
Musclebear2b made it! (author)2014-03-16

I'm a mac user too, and I found, through all my searching for ways to do it, Apple Pi baker - http://www.tweaking4all.com/hardware/raspberry-pi/...

Its a nice easy GUI way to format an sd card in preparation for flashing an img onto, flashing imgs to sd cards, and cloning them for backups.

Flashing a NOOBS image takes only a few minutes, and works perfectly every time.

author
scottkildall made it! (author)scottkildall2014-03-16

Thanks for sharing! Looks like NOOBS is a solid, useful GUI solution.

My guide is definitely all about the command line, which is good...if you want to get in deep and learn more about the command line.

author
Musclebear2b made it! (author)Musclebear2b2014-03-16

This will flash any img to an sd card, not just noobs. But it only works on mac

I'm pretty much a noob myself at all things pi, and I recently ordered an lcd touch screen for mine, and the instructions given aren't particularly in-depth for installing it onto an existing build, so I was practicing on a new build.
There is an img with the lcd driver already, but being a noob, each tweak I made changed something that stopped the screen working properly, so I reflashed the sd card a lot. Not something I'd want to be doing if it took 45 minutes each time!

I'm all for learning to get to grips with the command line - in fact, I've just installed debian onto an old vista laptop so I can practice - but when you're new to something, you want quick and easy successes which encourage you to learn more, rather than drawn out boring processes...

author
nevyn.hira made it! (author)nevyn.hira2015-06-10

:) My introduction to Linux has a long one full of dial up speeds and wanting to learn it *all* now! I ended up playing with Linux from Scratch and

Best tips for your situation:-
* If you're doing things like compiling modules and mucking around with the kernel. This is really hard and chances are you're going to find yourself often more frustrated than not. In this scenario, once you've imaged one SD Card, image a second one... So while you're mucking around, you're also creating a whole new SD Card which means your mucking around need never stop!
* If you are compiling modules.... chances are someone's already gone through all the pain. Look for ppa's (personal package archives) and the like.
* Otherwise, keep a pen a paper handy and take note of your changes. Since 90% of Linux can be configured via text files, reversing changes is also fairly trivial.

author
kd7eir made it! (author)2015-06-07

If you are going to hook a monitor up at the beginning, why not do all of your configuration that is possible through the monitor?

If you do not have an HDMI monitor, then simply connect to the Pi with a serial cable, use Putty to connect to it, and then configure it from there. I just do not see the point of using the monitor for one step, and then resorting to command line configuration for everything else, particularly for new users.

Is this instructable meant to be more of a lesson in linux command line configuration than an actual Raspberry Pi configuration guide? I just cannot wrap my head around doing things the hard way. Configuring wifi when you have a monitor attached takes about 15 seconds and shows you the assigned ip address, eliminating the need for additional software, an ethernet cable, and "treasure hunting" for the ip.

Please enlighten me as to why this instructable takes the most difficult route to accomplish it's task, adding onion-like layers to what can truly be a simple task.

author
scottkildall made it! (author)scottkildall2015-06-07

It would be helpful if you were to actually provide the specific steps to accomplish this, rather than just critiquing the Instructable itself.

Do realize this: I am no expert.

I would like to help others make Pi-based projects and will suggest alternatives, as needed.

Remember, be nice. We're all on the same side here.

author
nevyn.hira made it! (author)nevyn.hira2015-06-09

He's saying to just use a monitor. If you've had to use a monitor, then use it a little bit longer. When you're connected to a monitor for example, finding the IP address being used is as simple as running "ifconfig". No port scanning needed. No mucking around with routers etc.

If you don't have a monitor with HDMI input, look for something with DVI input. You can find relatively (around $6? I think I paid for one) cheap DVI-HDMI convertors (They both use the same signal so there's no processing involved).

As for the serial cable suggestion - I'd say that's a fail. If you want to use the onboard serial port, you'd need a signal shifter or a USB-Serial cable with 3.3V signal levels on hand (few inexperienced users will have this on hand - you'd usually use these with embedded applications i.e. network switches). It should be possible to do it with 2 usb-serial convertors though I've never done it this way (They're small enough to unplug, move somewhere with a monitor, check, put back for applications without a screen).

author
scottkildall made it! (author)scottkildall2015-06-09

That's right you can grab the ip address from ifconfig. Now, I remember why I used the IP scanner. My wifi router is in the other room with a short ethernet cable and lugging the monitor over is unwieldy. I'll adjust the Instructable accordingly and provide 2 different options. Thanks!

author
Jacoby Yarrow made it! (author)2014-05-15

Hi, I recently bought a Raspberry Pi and sd card preinstalled with NOOBS,I plugged it in to a TV via HDMI and plugged a 5v micro USB in and it does not boot up, I have tried everything on the Raspberry PI website.

Please Help,

author
nevyn.hira made it! (author)nevyn.hira2015-06-09

While the voltage will be correct, the amperage of your power supply probably isn't high enough. Also note, earlier pi's had some serious issues where power was concerned which necessitated the use of a powered USB HUB. There's a couple of tricks to get around this (I discovered that it could be powered via the USB port - which bypassed the fuses meaning that the one remaining USB port could supply as much current as required... which didn't really help as I still needed a powered hub... it's just that I could remove the power supply cable).

The other issue you may have (try a different distribution i.e. load up a new SD card with something different) is a corrupt installation. The question is, what do you mean by "does not boot up"? i.e. at what point does it fail? Does it show the colours? Does it get to showing you boot messages? Does it seem to boot and then get stuck? Does it seem to boot and then just seem to reboot?

author
joedix made it! (author)joedix2015-06-07

what is the power output rating of your micro USB? or are you trying to get power from a TV?

author
Spannerman107 made it! (author)Spannerman1072014-10-08

Only once everything is plugged in and powered up should you plug in the keyboard USB. I found that with mine, it was drawing too much power from being plugged in initially thereby preventing the Pi feom powering up

author
scottkildall made it! (author)scottkildall2014-10-08

Interesting. I saw this problem but only when I was using the HDMI camera and a bunch of other peripherals of the USB. I found that the Pi would reboot when the camera module was activated. Ended up running the USB off a separate power supply, which solves the problem.

author
tzq33tdq made it! (author)tzq33tdq2014-05-23

When you power it on, cycle through keys: 1 -> 4 and F1 -> F4

author
scottkildall made it! (author)scottkildall2014-05-16

Hi Jack,

This guide is for a blank SD card, starting from scratch so that you can do command line work with Python.

I've never used NOOBS, but I think you probably want to check out the forums on the Raspberry Pi ssite:
http://www.raspberrypi.org/forums/

Good luck,
Scott

author
asteng88 made it! (author)2015-06-08

Worked perfectly for me.

Thanks for the tips

author
srhnz made it! (author)2015-06-08

You don't need to run a scanner to find the dynamic address for the Pi. Log onto the web management interface for your router and have a look at the DHCP lease list. Plug your Pi into the router and spot the new MAC address and the IP it has been assigned. Whilst you are in there, have a look at the range of the DHCP IP pool. Any static address you assign to the Pi should be outside this range to avoid possible IP conflicts with other DHCP clients.

Raspian Wheezy uses the WPA-Supplicant for wifi configuration. Your interfaces file should look like this:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
address 192.168.XX.XX <- Use your own IP address choice
netmask 255.255.255.0
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Your wpa-supplicant file should look like this (a VERY basic config)

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MyWifiNetworkSSID"
psk="MySuperSecretPassphrase"
}

Of course, if you are using a Mac or have a Linux box, you can set this all up before you even boot the Pi by directly editing the various files on the mounted SD card partition.

author
jdawgaz made it! (author)jdawgaz2015-06-08

ok. I think I see re: the interfaces file, and the wpa_supplicant.conf file.

I can still have multiple networks in the wpa_supplicant file, all using that static ip address in the interfaces file?

author
scottkildall made it! (author)scottkildall2015-06-08

Thanks for sharing!

author
jdawgaz made it! (author)2015-06-08

make that known hosts file (not unknown hosts)

author
scottkildall made it! (author)scottkildall2015-06-08

You are correct.

For those out there way to do this, in the Terminal window:

cd ~/.ssh
nano known_hosts

ctrl-K deletes a specific IP + key.
ctrl-X + Y + Return will save the file

This will leave the known hosts file intact and is a better way to handle the RSA/Fingerprint error. It's slightly more steps and can be confusing for the beginner.

author
jdawgaz made it! (author)2015-06-08

by the way, on the mac, you don't have to delete the unknown hosts file. that is like taking a sledgehammer to kill a gnat.

Just search for and delete the offending line. leave the rest in there.

author
nevyn.hira made it! (author)2015-06-07

Getting your IP address this way is going to make you cry...

This is because the IP address that your Raspberry Pi is assigned is going to be dependant on configuration of whatever is providing that address. i.e. it's *VERY* common for your address to be in the range 192.168.*.* (where * can be any value between 1 and 255) OR in 10.*.*.*. Less common is an address within the range 172.16.0.1 - 172.31.255.255.

So... get on another computer on the same network, find it's IP address (in Linux and Mac you'd run ifconfig in a terminal. In windows, it's ipconfig in the command prompt) and use that range i.e. if your desktop computer gets an IP address of 192.168.2.101, it's reasonable to assume that the address your raspberry pi has been given is within the range 192.168.2.1 to 192.168.2.254. Likewise, if your computer has an address of 10.0.1.20, it's reasonable to scan 10.0.1.0 to 10.0.1.254.

If you know how, it's worthwhile setting a "static lease" for the raspbery pi in your DHCP server - this gives it the same address EVERY time, and makes it easy to change that address if you ever need to. Otherwise, you can set a static address (in /etc/network/interfaces) on the Raspberry Pi itself.

author
scottkildall made it! (author)scottkildall2015-06-07

Can you outline the steps for setting a "static lease"? Thanks!

author
nevyn.hira made it! (author)nevyn.hira2015-06-07

The problem here is that the way to get set up a static lease is going to be completely reliant on the DHCP server - usually part of your router/modem which means that the interface (and ability to do so - I'm surprised by the number of vendors that don't include an interface to set static leases) to do it can be different for every piece of kit. If you do this, assign the Raspberry Pi an address OUTSIDE of the range that the DHCP server is serving up (but within the same subnet).

If you are able to see the leases your DHCP server has served up though, it's a hell of a lot quicker getting an IP address that way rather than scanning the network.

author
negativequity made it! (author)2015-06-07

if you do want to set a password, change your keyboard settings (if necessary) first. otherwise you'll set your password using a UK keyboard which could make entering it difficult if you change the settings later

author
scottkildall made it! (author)scottkildall2015-06-07

Good point! Hadn't thought of that one.

author
Ralphxyz made it! (author)2015-06-07

Darn your download does not work!!

Great article, you share things I have been looking for.

author
scottkildall made it! (author)2015-05-25

This technique works for *most* networks, but there may be some peculiarities. I'd double-check the steps in the Instructable again. You may have to redo the steps, which is, not uncommon with the Pi.

If that doesn't work and you have the same problem with the wifi not working, I'd suggest posting the specifics to the Raspberry Pi forums, where some folks might be able to track down your specific situation:

https://www.raspberrypi.org/forums/

Good luck!

author
askthecableguy made it! (author)2014-04-21

thanks for sharing. what else have you done with your Pi?

author
scottkildall made it! (author)scottkildall2014-04-30

I'm working on a project called "Bot Collective" — series of Twitterbots with the Raspberry Pi, that have physical "bodies". Some of which will be mobile with electronics. Website (under development) is www.botcollective.com

author
winkleink made it! (author)2014-03-17

Raspian SSH is enabled as standard.For Headless configuration I plug my Raspberry Pi into the Router with an Ethernet cable and use my routers control panel (web interface) to get the dynamic IP address for the Pi.

I can then SSH to the IP address and log in. (You might have to press [enter] to make the login prompt appear)

Once logged in the rest of the customisation here can be done.

For my personal setup where I have my laptop next to my Raspberry Pi I do static IP on a different subnet for my laptop Ethernet port and the Raspberry Pi Ethernet Port and then DHCP for wifi on the laptop and the Pi.

In this way I connect to the Pi over 100Mbs connection rather than wifi (I know shares the same USB bus on the PI, but should make a little bit faster) and both my computer and the Pi can use their wifi to connect to the Internet.

Example:

Laptop.
----------

Ethernet Port IP: 10.0.0.100. Do not set Broadcast or Gateway otherwise the computer thinks it can use this IP address to connect out.

Wifi (DHCP): in the range: 192.168.1-100

Raspberry Pi:
----------------

Ethernet Port IP: 10.0.0.101. Do not set Broadcast or Gateway.
Actually you only need address and subnet

Wifi (DHCP) in the range 192.168.1-100

author
scottkildall made it! (author)scottkildall2014-03-17

Thanks, you know more about network settings that I do.

Q: I have two scenarios for my Raspberry Pi setups:

(1) A Pi which is a Twitterbot, and needs to connect to the larger world
(2) A Pi which is a GitPi server and needs to connect just to my home network

What would you advise for network, broadcast and gateway settings for each?

Currently, I have these — which are working fine:

network 10.0.1.0
broadcast 10.0.1.255
gateway 10.0.1.1

author
winkleink made it! (author)winkleink2014-03-17

Hi Scott,

Maybe a little, but only from tinkering.

Scenario (1)
Maybe add the netmask (usually 255.255.255.0)
Then your adaptor knows for IP addresses outside of 10.0.1.0 and 10.0.1.255 it needs to use the gateway

Scenario (2)
You should be able to remove the gateway and broadcast assuming the Pi doesn't need to connect externally.
It doesn't really make a difference as the Pi with the static IP is still listed on the router, so computers can connect to it.
If this Pi doesn't request external (Internet) traffic then the extra settings aren't doing anything.

Personally I'd leave the settings as they are and add the netmask.
For Scenario 2 if you want to do a sudo apt-get update && sudo apt-get upgrade or a sudo apt-get install you can do it without messing with your settings.

have fun with the Pi.

Albert.


About This Instructable

383,815views

1,676favorites

License:

Bio: Scott Kildall is an new media artist and researcher. He works at Autodesk, Pier 9 and is an artist-in-residence with the SETI Institute
More by scottkildall:Pier 9 Guide: Fusion 360 to OMAX WaterjetStrewn Fields: Waterjet Etching Into StonePier 9 Resource: Setting up 2D profiles for CNC in Fusion 360
Add instructable to: