kracheck
Posts: 4
Joined: Sat Mar 29, 2014 4:38 pm

Flash Raspbian on SDcard for use with static ip

Sat Mar 29, 2014 7:00 pm

1. Insert the SDcard into your pc and find out where it is mounted by typing : sudo fdisk -l or df -h (/dev/sdb in my case)
2. Copy the raspbian image to the SDcard : dd bs=4M if=~/2014-01-07-wheezy-raspbian.img of=/dev/sdb
3. Sudo sync (this will ensure the write cache is flushed and that it is safe to unmount your SD card) - Remove the card
4. Flash Raspbian on the SDcard and alter the outfome for use with a static IP - Insert the card

a. Mount SDcard

b. sudo fdisk -l or df -h will show the mounted partitions of the card. There are two. A'boot' partition and a 'file system' partition.

c. type 'mount' to find the location of the mounted 'file system' partition

d. Go to the location of the mounted 'file system' partition and look for the network directory. In my case :
cd /media/fc254b57-8fff-4f96-9609-ea202d871acf/etc/network

e. In the network directory backup the interfaces file
sudo cp interfaces interfaces.bak

f. Edit the interfaces file (sudo nano interfaces) and make it look like below

auto lo
iface lo inet loopback
#iface eth0 inet dhcp

auto eth0
iface eth0 inet static
address 192.168.0.125
netmask 255.255.255.0
gateway 192.168.0.1

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

g. Unmount the SDcard and plug it in the pi. Boot and ssh to the static address 192.168.0.125

User avatar
default_user8
Posts: 680
Joined: Mon Nov 18, 2013 3:11 am

Re: Flash Raspbian on SDcard for use with static ip

Sat Mar 29, 2014 7:30 pm

Or your could have your router reserve an ip address for your pi by mac address.
Two heads are better than one, unless one's a goat head.

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: Flash Raspbian on SDcard for use with static ip

Sat Mar 29, 2014 10:56 pm

default_user8 wrote:Or your could have your router reserve an ip address for your pi by mac address.
This doesn't work for all setups. Let the man be helpful. People ask about doing this all the time!

User avatar
default_user8
Posts: 680
Joined: Mon Nov 18, 2013 3:11 am

Re: Flash Raspbian on SDcard for use with static ip

Sun Mar 30, 2014 3:36 pm

Just presenting another option, seems that many people fight to make this work when they don't have to, most(not all) routers will do this for you(it's the routers job).
Two heads are better than one, unless one's a goat head.

timm71104
Posts: 1
Joined: Sun Mar 30, 2014 10:43 pm

Re: Flash Raspbian on SDcard for use with static ip

Sun Mar 30, 2014 10:54 pm

Once you perform this setup, would you be able to boot the pi and telnet to a login prompt? Or to a VNC session?

Thank you for posting this, I have had my Pi for a while now and would like to start using it, preferably by using either telnet or VNC so I do not have to have an external monitor and keyboard.

User avatar
default_user8
Posts: 680
Joined: Mon Nov 18, 2013 3:11 am

Re: Flash Raspbian on SDcard for use with static ip

Mon Mar 31, 2014 1:46 am

Yes you will be able to use telnet or vnc, but you can do that already by using the ip address assigned by your router to your pi. Keep in mind you will have to alter the instructions to match the range of ip addresses made available by your router. If you use this tutorial you don't have to set your router to give your pi a static address, it will request the same ip address every time it connects to your router. Hope this answers your question.
Two heads are better than one, unless one's a goat head.

kracheck
Posts: 4
Joined: Sat Mar 29, 2014 4:38 pm

Re: Flash Raspbian on SDcard for use with static ip

Mon Mar 31, 2014 7:46 am

I should have pointed out that my network uses static ip addresses only. The DHCP server on my linksys E3200 is set to 'disabled'. DHCP reservation of an IP address based on the mac address of the device is indeed possible on a router level but requires, at least in my case, DHCP enabled. I don't want DHCP. Also I don't know about a possbility to find out the mac address (ifconfig eth0) of the pi before beeing connected to it. Is it written on the device ?

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: Flash Raspbian on SDcard for use with static ip

Mon Mar 31, 2014 8:02 am

kracheck wrote:I don't know about a possbility to find out the mac address (ifconfig eth0) of the pi before beeing connected to it. Is it written on the device ?
Assuming you have a keyboard and display connected to the Pi, you can still find the MAC address with no active network connection thus...

Code: Select all

cat /sys/class/net/eth0/address
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

kracheck
Posts: 4
Joined: Sat Mar 29, 2014 4:38 pm

Re: Flash Raspbian on SDcard for use with static ip

Mon Mar 31, 2014 8:52 am

Good to know. Thanks

Return to “Beginners”