Day 6 Setting a static IP address

This is a quick easy one.

Setting an static ip address is very simple.

All you need to do is make a small configuration change to your ‘interfaces’ file found in /etc/network/

But first things first. Make a copy of your ‘interfaces’ file with a different name.

Presuming that you followed the earlier example of altering your ‘interfaces’ file all you need to do is copy the iface default inet static section entering your local network details where indicated.

e.g.

auto lo

auto wlan0

iface eth0 inet dhcp

allow-hotplug wlan0

iface wlan0 inet manual

wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet static

address [insert your address here] e.g.      192.168.100.2

netmask [insert your netmask here]  e.g.  255.255.255.0

gateway [insert your gateway here] e.g.     192.168.100.1

 

remember to save your file and reboot.

Day 5 Getting my Pi to sync with time servers

Eventually my Pi will help me when I’m making my famous home brew. However to do that I need it to keep accurate time.

If you already own a Raspberry Pi then you will know that there is no real time clock. The solution to this is to use NTP  (Network time protocol) connecting to a time server.

To check the current system time type ‘date’ from a shell

This is where my Pi falls over. It will not keep accurate time.

To rectify this you have to alter a system config file, but first we will be backing up this file just in case of any mistakes.

The file in question is called ntp.conf and can be found in the /etc folder.

To back up the file type the following:

‘sudo cp /etc/ntp.conf /etc/ntp_backup.conf’

into your shell. If you are like me and using your Pi as a headless server then logging in using ssh will land you at a command line. If your using the desktop then start up a command line from the shortcut on your desktop.

Right, next is setting the time servers. I live in the UK so these will be set to ones within the UK.

Type ‘sudo nano /etc/ntp.conf’

you will see on the page something like this:

server 0.pool.ntp.org iburst

server 1.pool.ntp.org iburst

server 2.pool.ntp.org iburst

server 3.pool.ntp.org iburst

Change this to your local time servers. Navigate to http://www.pool.ntp.org/en/use.html to find yours.

Example if your in the UK you should change the entry in your ntp.conf file so it looks like this.

server 0.uk.pool.ntp.org iburst

server 1.uk.pool.ntp.org iburst

server 2.uk.pool.ntp.org iburst

server 3.uk.pool.ntp.org iburst

Finally further down the file you will see the following:

restrict 127.0.0.1

restrict ::1

comment these out by inserting a ‘#’ (without quotes) at the beginning of these lines

press crtl + x then ‘Y’ will save your changes

Ok now that is done the next stage is to update the time. you can reboot or:

type ‘sudo service ntp restart’

followed by ‘date’

You now should have the current time and date displayed every time you type ‘date’

Happy time keeping 🙂

 

Day 4 Starting a fresh

For some reason unknown to myself I decided to wipe my SD card and start a fresh.

Since I had most of my configuration files backed up this would not normally have  been a problem. I was sooo wrong.

Nothing worked. After 2 hours of checking the files again i noticed that the /etc/network/interfaces file had a entry in it what was ‘wlano’ instead of wlan0. oh how i swore.

Anyway I have a new clean install now that is connected to my home network as we speak.

Once I get my pi up and running how i like it. The next item on the agenda will be to try and take and image of the updated / built Pi.

Day 3 setting my pi to mount network drives at startup

Another day and another challange.

First off i’m going to use a samba share instead of a NFS with this one.

To mount any network share you need to amend your FSTAB file.

A word of caution first though. You will be messing with system configuration files that can have the potential to destroy your system to the point where where it will not boot and you will have to re-image your sd card.

First off you will need to make a mount point. To do this log into your Pi and create a new directory where you want your share to be mounted to. for instance type ‘sudo mkdir /home/pi/desktop/My_network_share’

then create a file called ‘.smbcredentials’ in the home directory  ‘/home/pi’

enter your log in details for the share in this format, save and exit:

username=MyUsername
password=MyPassword

Next you will have to amend your FSTAB file

To get to your FSTAB file type ‘sudo nano /etc/fstab’

this will open up your file and you should see something like this:

/dev/mmcblk0p1  /boot      vfat    defaults          0       2
/dev/mmcblk0p2  /        ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, so no using swapon|off from here on, use  dphys-swapfile swap[on|off]  for that

 

amend the end of the file with the following, remember to put your share details in where indicated.

//<share IP address/<share path>  /home/pi/Desktop/<My_network_share>  cifs credentials=/home/pi/.smbcredentials 0 0

save the file and exit.

Next make sure your share will now  mount by typing ‘sudo mount -a’

you should now be able to ‘cd’ to the new file path.  If not then make sure you have put in the correct path in your now amended FSTAB file and try again.

All being well you should have a working share point 🙂

 

 

Day 2 Setting up wireless for the first time

Yes don’t tell me, I know I’ve written this on the same day as Day 1 post. Just playing catch up with what I’ve done so far.

Wireless. setting up etc etc.

This time things were a little easier. I’m using a EDIMAX nano wireless USB adapter EW-7811Un

And for all that want to follow what i did:

First off make sure that SSH is turned on. if you don’t know how to do this then go back to the config page that you will have got when first turning the Pi on. To do this from a command line type ‘sudo raspi-config’ select the ssh option and turn it on, select finish and your Pi will reboot.

Imageyou will need this later if you intend to do what I’m doing and turn it into a headless server, (no monitor connected).

plug in the wireless adaptor and restart you pi again.

log in as admin, the Pi account will be ok then type ‘lsusb’. You should see the wireless adaptor listed as here:

Image

next you need to alter the config files found in the /etc folder using nano:

/etc/network/interfaces
/etc/wpa_supplicant/wpa_supplicant.conf

copy what’s here into the interfaces file:

auto lo
auto wlan0

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

iface default inet dhcp

and the supplicant.conf file:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_conf=1

network={
ssid=”<YOUR SSID GOES HERE>”
psk=”WIFI PASSWORD GOES HERE”
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
auth_alg=OPEN
}

Remember to alter the above for your ssid and passcode, once saved reboot and that’s it, all should be well and your Pi will be connecting to your wireless network on next reboot. Using a DHCP assigned ip address

Raspberry Pi (day 1)

Image

 

First day and first experiences setting up my new raspberry pi.  The ultimate goal is to have it set up as a headless server doing cool projects for me in the background.

First impressions on this was “this will be sooooo easy” I have a background with Linux so installing a new Debian OS on a SD card should have been a walk in the park.

Oh how I was wrong. Getting the image on the SD card using linux was the first hurdle.

Four hours of faffing around got me nowhere. Leading me back to the ‘simple steps’ setting it up. Started to think that I should have got the pre-loaded SD card when I ordered my Pi.

After a while though things started to look up. Wheezy image installed on a 2GB SD card and successfully started my Pi on a TV using the HDMI cable. 🙂