Having lost my original SD card image when the card failed, I needed to rebuild my Raspbian configuration. This is the outline of the process I used to rebuild the image and configure Raspbian and OpenVPN to act as the wireless bridge between the two houses. I started the process with a fresh NOOBS based install of Raspbian.
Step 1: Update Base Install
Firstly, I need to update the packages to the latest versions. I open a connection to my Pi 2 with Putty from my Windows box.
I execute the commands:
sudo apt-get update
sudo apt-get upgrade
The first command updates the package metadata so that apt knows what is available. The second command scans the system, prompts for permission then downloads and installs the updated packages.
Step 2: Configure eth0 and wlan0 network interfaces
Next I need to configure the IP addresses used by the Pi 2. DHCP assigned addresses aren't suitable for a device intending to act as a network gateway, so I need to configure static IP addresses for both eth0 (Wired LAN) and wlan0 (WiFI).
I execute the command:
sudo nano /etc/network/interfaces
Then I delete the existing contents and use the following config (My actual IP's have been masked)
iface lo inet loopback
iface eth0 inet static
iface wlan0 inet static
Next, I need to disable the DHCP Client Daemon (dhcpcd) which I found assigns the network interfaces a DHCP address even though I have set a static IP above.
To do this I use the command:
sudo update-rc.d dhcpcd disable
Step 3: Set Hostname & GPU Memory Split
Now I just need to configure the Hostname and the amount of RAM assigned to the GPU in the Broadcom SoC before rebooting. Since the GPU will not be needed I will be assigning it 16MB of RAM which is the smallest amount possible. To perform this configuration I will use the 'raspi-config' utility.
I use the command:
First I set the Hostname. I access the 'Advanced Options' menu, choose 'Hostname' and enter 'Eienstein'.
Then I set the GPU Memory. Again I access the 'Advanced Options' menu, then I choose 'Memory Split' and enter '16'
I then choose the 'Finish' option to complete the process. I am prompted to reboot and choose 'Yes' which reboots the Pi 2.
Step 4: Enable IP Forwarding
After waiting a couple of minutes and reconnecting to the Pi on it's new IP address, I am ready to enable IP Forwarding which allows the linux kernel to route packets between interfaces by using the routing table.
I execute the command:
sudo nano /etc/sysctl.conf
I locate the line containing '#net.ipv4.ip_forward=1' and remove the hash to uncomment the line. This script is used by linux during the boot process to configure certain system parameters, in this case forwarding of IPv4 packets.Next I execute the command:
sudo sysctl -p /etc/sysctl.conf
This causes the system to reload the configuration file and apply the changed settings.
Step 5: Configure Wireless Access Point for wlan0 interface
Now I need to configure the wlan0 (WiFi) interface to act as a Wireless Access Point so the other box can connect to the wireless network without requiring a dedicated access point. I need to install the 'hostapd' daemon in order to act as the access point.
I run the commands:
sudo apt-get install hostapd
sudo nano /etc/hostapd/hostapd.conf
The first line uses apt to download and install the daemon, the second line created a new configuration file for the daemon. I use the following config (again masking identifying details)
This config sets up an 802.11g Wireless LAN on channel 11 which in my...
Read more »