A cool distro

An ultra light version of Debian can be found at

https://dietpi.com/

 

Advertisements

Building a PI Wireless repeater

This is Tim’s definitive set of notes that tells you how to make a wireless repeater from a pi

Based largely on
https://seravo.fi/2014/create-wireless-access-point-hostapd

we have to have hostapd installed
we also have to have dnsmasq installed

utils for checking what the state of the pi is

iw wlan0 info
ifquery wlan0
ifconfig -a
lsusb

#######################################
# this is the /etc/network/interfaces file
#######################################

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet static
 address 192.168.0.198
 netmask 255.255.255.0
 gateway 192.168.0.1
wpa-ssid aaaaaaaaaa
wpa-psk bbbbbbbbb

auto wlan1
iface wlan1 inet static
hostapd /etc/hostapd/hostapd.conf
 address 192.168.2.2
 netmask 255.255.255.0

###########################
# this is the /etc/hostapd/hostapd.conf file
#######################################

interface=wlan1
ssid=anewhope
hw_mode=g
channel=1
wpa=2
wpa_passphrase=r3becca3ll
wpa_key_mgmt=WPA-PSK WPA-PSK-SHA256

#######################################
# other bits
#######################################
uncomment in /etc/sysctl.conf

net.ipv4.ip_forward=1

in /etc/dnsmasq.conf we need

interface lo,wlan0,wlan1
no-dhcp-interface=lo,wlan0
dhcp-range=192.168.2.50,192.168.2.254,255.255.255.0,6h
sysctl status dnsmasq
sysctl start|stop dnsmasq

#######################################
# finally some forwarding
#######################################
in rc.local, before the exit line we put the following iptables line

iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE

Sorting out Excel Comments

The following Macro reformats the comments in  a spreadsheet when the Excel bug has messed them all up …

Sub AutosizeComments()
 ' Alt F11 + Insert - Module
 ' Insert this macro then close the VBA
 ' then alt F8 to run and select the AutoSizeComments option
 ' moves the comments to rght by where you need them, adjust width and Heght as you see fit
 Dim cmt As Comment, cell As Range
 On Error Resume Next
 For Each cell In ActiveSheet.UsedRange
 Set cmt = cell.Comment
 If Not cmt Is Nothing Then
 cmt.Shape.Placement = xlMove
 cmt.Shape.Left = cell.Left + cell.Width + 30
 cmt.Shape.Top = cell.Top + 10
 cmt.Shape.Width = 200
 cmt.Shape.Height = 150
 cmt.Shape.Left = c.Offset(0, 1).Left
 cmt.Shape.Top = c.Offset(-1, 1).Top
 End If
 Next cell
 End Sub

Connecting a Raspberry Pi Zero over USB

Some notes on how to use a Pi Zero without a lot of adapters and cables.

The Pi Zero is a cool bit of kit which has amazing capabilities but tends to need a spaghetti of wires to get it connected and up and running.

I read on the internet that the device can be used in a USB on the Go mode and in order to have a device that I can use pretty much anywhere I thought I’d give it a go.

I followed the instructions on the page http://blog.gbaman.info/?p=699 which are pretty self explanatory, although there were a couple of areas that weren’t entirely clear to me that I think I will clarify…

To make life easy, I used a Raspberry Pi 2 which I have to prepare the card ready for the Pi Zero. I downloaded the latest Raspian Jessie full implementation from the Raspberry Pi Foundation download page, expanded it from the zip file under Windows 10 and then wrote it to a Micro SD card using Win32Imager.

Once the writing was complete, I loaded the card into my Pi 2 with the easy to access ports and network to allow me easy access to the installed version to prepare it.  All the steps that you need to do can be done on this device, other than the update of the Pi firmware. (On my Pi Zero it was at the latest firmware level already so although that is in the instructions, if you got your Pi Zero in 2016 I suspect that you will be up to date enough for it to work)

The steps I used to get the Pi prepared were as follows

  • boot with keyboard, mouse and screen
  • set the Pi to boot to the command prompt as shown here and reboot
  • resize the root partition (sudo raspi-config, select expand and reboot)
  • add the line dtoverlay=dwc2 to /boot/config.txt (used sudo vi)
  • add the lines dwc2 and g_ether to /etc/modules (used sudo vi)
  • shutdown
  • the card is now mostly prepared and can be put into the Pi zero
  • I connected a power cable to the power socket and a network cable to a USB ethernet adaptor
  • I checked my router to find the IP address of the Pi Zero
  • Use ssh to log on to the Pi and then run the firmware update  sudo BRANCH=next rpi-update
  • Finally I added the config to the /etc/dhcpcd.conf file (sudo vi)
    interface usb0
    static ip_address=169.254.64.64
  • shutdown

This was all the prep and all that remained was to test the Pi

I plugged a standard USB cable into my PC and the mini end into the Pi, not into the Power port, but into the USB port. The PC is quite capable of providing the power for the Pi zero, so it becomes a single wire connection

It took a while for the drivers to be downloaded and installed for the USB ethernet

When it is recognised it appears as an adapter in the Control Panel ¬ Network and Internet ¬ Network Connections

You should be able to ping 169.254.64.64 from your PC and then ssh to 169.254.64.64 to access the Pi.

Remember this doesn’t give you access to the Internet from the Pi, but it does let you use it as a webserver or SQL database or programming test environment if you chose from any other computer, once config has been done.

 

Auto mounting drives at boot under OSX

I keep losing this nugget of information and after having just re IP addressed my network, this is now needed

OSX runs stuff using /etc/auto_master

Mine looks like this

hopenet-mac-mini:etc tim$ cat auto_master
#
# Automounter master map
#
+auto_master # Use directory service
/net -hosts -nobrowse,hidefromfinder,nosuid
/home auto_home -nobrowse,hidefromfinder
/Network/Servers -fstab
/- -static
/- auto_smb
hopenet-mac-mini:etc tim$

The last line points to a file

/etc/auto_smb

hopenet-mac-mini:etc tim$ cat auto_smb
/mount/media_server -fstype=smbfs ://guest:guest@192.168.1.250/files
/mount/movies -fstype=smbfs ://guest:guest@192.168.1.250/movies
/mount/music -fstype=smbfs ://guest:guest@192.168.1.250/music
/mount/mp3 -fstype=smbfs ://guest:guest@192.168.1.250/music/mp3
/mount/pictures -fstype=smbfs ://guest:guest@192.168.1.250/pictures
hopenet-mac-mini:etc tim$

These links provide guest access to the server and persist…

Who's the techno daddy?