pBook‎ > ‎

Raspberry Pi

1. make internet shared by double clicking on wireless internet and going to share tab. 
2. make a static ip over your lan network: 192.168.1.XXX and subnet mask of 255.255.255.0
3. create ssh connection to your pi: ssh pi@192.168.1.YYY
4. go too root folder, in /etc/network
5. sudo vim interfaces
6. add these lines: make sure you obtain them before by 
6.a ifconfig 
6.b sudo route -n
6.c 
address 192.168.1.yyy
netmask 255.255.255.0
network [your destination]
broadcast [your broadcast range]
gateway 192.168.1.XXX


7. you might still need to edit cmdline.txt
7.a go too boot/
7.b sudo vim cmdline.txt
8. add this line
ip=yourrasip::yourstaticlanip
9.:wq
10. sudo reboot


 |  
Search

How to setup a static IP address on your Raspberry Pi

January 14, 2015

So, you want to connect remotely to your Raspberry Pi? For that you’ll need its IP address! There are two main forms of IP address, dynamic and static. By default, your Raspberry Pi will have a dynamic IP address. This means that the IP address can change at any time - not ideal if you want to run your Raspberry Pi headless, as you’ll need to keep checking and updating the IP address in your system. A static IP address however will not change, it assigns your Raspberry Pi a permanent address on your network - so you know exactly where it is at all times. 

Setting up a static IP address on your Raspberry Pi can seem like a daunting task, but fear not, we’ll walk you through it one step at a time in this tutorial.

For this guide, we’re going to assume that you are running the latest version of the Raspbian operating system as it is the most common amongst Raspberry Pi owners. 

Step 1. Check your connection!
First up we’ll need to double check that your Raspberry Pi is happily connected to your network. A great way to do this is to run sudo ifconfig


As you can see in the above screenshot, our Raspberry Pi is connected to our network and has been given the IP address 192.168.3.116 (yours will likely be different!)

Step 2. Make some notes!
Before we can begin applying a static IP address to your Raspberry Pi we’ll need to gather the necessary data from it! We can get a lot of this from the “ifconfig” command we ran earlier. Make a note of the following data:

Current IP Address (inet addr)
Broadcast Range (Bcast)
Subnet Mask (Mask)

so, from our example, I would get the following information.

Current IP Address = 192.168.3.116
Broadcast Range = 192.168.3.255
Subnet Mask = 255.255.255.0

Different networks will give you different data, so make sure you don't just copy our results!

With those noted down, run sudo route -n, this will give us information from your router.



Make sure you note down the following information given from this command:

  • Gateway
  • Destination 


So from the example, I would get the following
Gateway = 192.168.3.1
Destination = 192.168.3.0

OK, so we’ve now obtained all of the data that we need to setup our Raspberry Pi with a shiny new static IP address, it’s time to save it to a config file. 

Step 3. Edit the files
Time to run sudo nano /etc/network/interfaces . This opens the configuration file for the network settings in the nano text editor. If you’re more confident with an alternative text editor that’s fine too!



the line that reads “iface eth0 inet dhcp” is telling the ethernet “eth0” networking interface to use “dhcp” (dynamic IP). Firstly, replace “dhcp” with “static”.

Next up, add the following lines directly below the line you just altered, filling the []’s with the date you obtained above.

address [your chosen IP address]
netmask [your netmask]
network [your destination]
broadcast [your broadcast range]
gateway [your gateway]

Don't forget to save your file!

Here’s how my file turned out:



Step 5. Reboot!

run sudo reboot to restart your Raspberry Pi with its new static IP address. The changes we have made will only take effect after a reboot.



← Older PostNewer Post →


  • Bitcoin
  •  
  • Maestro
  •  
  • Master
  •  
  • Paypal
  •  
  • Visa

raspberry reinstall

posted Jul 3, 2016, 11:11 PM by Javad Taghia


How to Clone Your Raspberry Pi SD Card for Super Easy Reinstallations

If you've ever turned a Raspberry Pi into a media center or retro gaming station, you know how frustrating it can be when it crashes and corrupts your SD card. Here's a little trick to making that a little less painful.

Turn a Raspberry Pi Into an XBMC Media Center in Under 30 Minutes

The best home theater PCs are small, quiet, and inexpensive—so the bite-size, $35 Raspberry Pi is…Read more

The Raspberry Pi is a finicky little device. There was a period of time where my Raspberry Pi media center had a lot of trouble—every once in awhile, it would freeze or crash, requiring me to unplug it to get it going again, which would corrupt the SD card. While the problem was caused by a bad power supply, it took me awhile to diagnose, and it was really annoying to have to set up the Pi from scratch every time this happened.

So, I came up with an idea: After installing XBMC and getting everything set up just the way I want it, I'd clone my SD card. That way, if and when it crashed next, I could just copy my all-set-up image back to the SD card, put it in the Pi, and be up and running again in minutes instead of hours. I highly recommend everyone do this to the SD card for their Pi, no matter what you're using it for. It'll make your life a lot easier.

The Ultimate Start to Finish Guide to Your XBMC Media Center

XBMC is a fantastic and free cross-platform media center application we're nuts for. If…Read more

Cloning the SD card is simple. Just follow these steps:

  1. Get everything set up just the way you want it on your Raspberry Pi, whatever you're using it for. Then shut down the Pi and remove the SD card. Insert the SD card into your computer.
  2. Start up Win32DiskImager, a program that you probably have from when you first set up your Pi. (If you're on OS X or Linux, you'll have to use the dd command as described here instead of these steps).
  3. In the "Image File" box, enter the path of your soon-to-be image file. For example, I put mine in C:\Users\Whitson\images\myraspbmc.img
  4. Under the "Device" box, select your SD card.
  5. Click the "Read" button to create the image file from your card.
  6. When it's done creating the image file, you can eject your SD card and put it back in your Raspberry Pi. Keep that IMG file in a safe place.

Now, if anything ever goes wrong with your Pi, you can restore your fully-set-up image using the reverse instructions:

  1. Insert the SD card back into your computer.
  2. Head to the start menu or screen and type "disk management." Open the disk management program and find your SD card in the list.
  3. Right-click and delete all the partitions on your SD card. When it's empty, right-click on it and format it (it doesn't matter what filesystem you format it to, your computer just needs to recognize it).
  4. Open Win32DiskImager again and browse for your image file. Select your device from the Device dropdown just as you did before.
  5. This time, click "Write" to write the image to the SD card.
  6. When it finishes, eject the SD card and re-insert it into your Raspberry Pi. When you boot it up, it should be in the exact same state it was in when you first cloned the SD card.

Once you've done this, setting up your Pi from scratch will be a whole lot simpler!

Photo by derkamener1984.

Reply52 replies
  • PorpoiseInAtreeWhitson Gordon

    Helpful, but this only works on the same Pi, right? I think I once tried this method thinking I would help out my friends with a freshly updated and configured XBMC build, but the serial of the Pi itself prohibited it from fully functioning (e.g. codecs)

    • Whitson GordonPorpoiseInAtree

      Yeah, I think it depends. Like akshay said, maybe certain things like licensed codecs may not work, but if you haven't registered something that's connected to your serial number, in theory it should work. I heard some people say you could do this to set up multiple Pis in the same HOUSE as long as you remembered to change their hostnames first.

      • GreenRainWhitson Gordon

        What prevents it from working on different Pi's? Is it a part of the install? The OS? I clone Wheezy SD cards with some software I wrote and have distributed to over 10 different Pi's without a problem.

      • biggggbWhitson Gordon

        For anyone who has OS with Terminal (OSX users, this is for you) something like this:

        backup:

        dd if=/dev/sdb of=sd.img bs=4M

        restore:

        dd if=sd.img of=/dev/sdb bs=4M

        • Craigbiggggb

          Great way to do it, but a couple notes.

          1) Make sure you know which device the SD card is, or you can mess up our hard drive. Do this by typing "df" and it should show you the SD card and how big it is. Also can be done in Disk Utility

          2) After doing the above, unmount the SD card prior to running "dd". This can be done at the command line or in Disk Utility.

        Load more
        Want Lifehacker’s email newsletter?
        Subscribe

        You may also like

        Lifehacker

        How to Build a Raspberry Pi Retro Game Console for $35 

        4/18/16 10:00am
        Lifehacker

        Everything You Need to Set Up Bluetooth on the Raspberry Pi 3

        4/01/16 1:00pm
        Lifehacker

        Easily Backup and Clone Raspberry Pi SD Cards

        8/12/14 1:30pm

        The Best File Management App for Android
        The Best Antivirus App for Windows
        The Best Photo Management Alternative for Android
        Sunday's Best Deals: Fire HD 6, GreenWorks Tools, Weather Radios

        1-1 of 1