Preparing a BPI- R1 for your IOT Data logging software such as EMONCMS, FreeBoard (and others)- actually the BPI-R1 is pretty nice- little bit of a bugger to configure off the top to get networking to work but works very nice afterwards…
here a simple howto for preparing BPi-R1.
fist download your image for your version of BananaPI
http://www.banana-pi.org/r1-download.html.
I used bananian as my base.
https://www.bananian.org/download
extract and write your image to your SD card
in windows use Win32 Disk Imager
in linux it is by commandline
dd if=bananian-1604.img of=/dev/<your-sd-card> bs=1M && sync
or use SUSE Studio Imagewriter ( which is what I use)
after you finish writing your image to your SD card insert into your bPI-R1 and boot up with your network cable connected
log in with putty/ ssh (ssh root@IPADDRESS) or connected directly with
root and the password pi
Preparation
Make sure the system is up to date:
apt-get update
apt-get upgrade
once that is done:
Run bananian-config
to edit configuration ie: password, keyboard, timezone …etc
Install needed software:
apt-get install bridge-utils iptables-persistent nethogs dnsmasq
Now Reboot
shutdown -r now or Ctrl-Alt-Del (if connected directly)
Configuration
swconfig — switch configuration
nano /etc/network/if-pre-up.d/swconfig
the base file is already configured in bananian all you need to do is edit out
exit 0
change it to #exit 0
save and exit
save => Ctrl-x then y then Enter
Interfaces
nano /etc/network/interfaces
edit your interface config to this adjusting the IPs to match your configuration
auto lo
iface lo inet loopback
allow-hotplug eth0
allow-hotplug wlan0
#link aggregation = use 2 Ethernet-Connections (bond0) to increase the speed
##### ** LAN config VLAN 1** ##########################
##### receive IP-Address from your DSL modem or cablemodem
auto eth0.101
iface eth0.101 inet dhcp
##### * LAN config VLAN 2, for the 4 ports * ###############
##### generate IP-Address for connected devices
auto eth0.102
iface eth0.102 inet manual
##### ** WLAN config ** ###############################
##### generate IP-Address for connected devices
auto wlan0
iface wlan0 inet manual
# you can take this option if you have a /etc/init.d/hostapd
# post-up service hostapd start
# -B run daemon in the background
# post-up hostapd -dB /etc/hostapd/hostapd.conf
# post-down, actions taken right after the iface is down
post-down rm -rf /run/hostapd/wlan0
##### ** Bridge config ** ###############################
auto br0
iface br0 inet static
bridge_ports eth0.102 wlan0
bridge_waitport 0
address 192.168.9.2
network 192.168.9.0
netmask 255.255.255.0
# adjust the gateway to your configuration, to match your internet gateway
gateway 192.168.0.1
Configuring dnsmasq
Configure the IP-Addresses:
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.example
nano /etc/dnsmasq.conf
edit/add these to your config file
interface=br0
listen-address=127.0.0.1
domain=home
domain-needed
bogus-priv
dhcp-range=192.168.9.150,192.168.9.250,24h
dhcp-host=dc:9f:dc:dc:dc:dc,192.168.9.149
Save and exit.
Configure DNS:
nano /etc/hosts
add this to your host conf
192.168.9.2 router
Save and exit nano.
Enable dnsmasq
nano /etc/default/dnsmasq
Look for the line that says:
ENABLED=0
and change it to:
ENABLED=1
Turn on IP forwarding in the Kernel:
to enable make changes here:
nano /etc/sysctl.conf
and uncomment line
net.ipv4.ip_forward=1
IPTABLES
to get VLans to talk to each other
iptables -t nat -A POSTROUTING -o eth0.101 -j MASQUERADE
iptables-save > /etc/iptables/rules.v4
now reboot and you should have a functioning router ( as an option reboot before entering and saving your iptables then you can pre test your firewall rules once they are working then save them)
For easier configuration install webmin (optional)
apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.840_all.deb
dpkg --install webmin_1.840_all.deb
if you need 1:1 NAT function on the router I found this to be the easiest way:
nano /etc/network/if-pre-up.d/swconfig
edit to look like this to create a third Vlan
ifconfig eth0 up
swconfig dev eth0 set reset 1
swconfig dev eth0 set enable_vlan 1
swconfig dev eth0 vlan 101 set ports '3 8t'
swconfig dev eth0 vlan 102 set ports '0 1 2 8t'
swconfig dev eth0 vlan 103 set ports '4 8t'
swconfig dev eth0 set apply 1
save and exit
then edit interface
nano /etc/network/interfaces
Based on the above for mention interface config file
iface eth0.101 inet dhcp
change this line to:
iface eth0.101 inet manual
then add these lines to it
auto eth0.103
iface eth0.103 inet manual
auto br1
iface br1 inet dhcp
bridge_ports eth0.101 eth0.103
save and exit
reboot
now the routers first 3 ports will assigned IPs for private network
the last two will act as bridge between each other for public IPs
-if installing NTOPNG it has issue with the and will crash but that because the version is abit outdated. but NTOP works fine if you wish to monitor both internal and external ports use the bridges br0 and br1 and or only one eth0.10X vlan
otherwise ntop will complain about identical MAC
Now you can install emoncms or FreeBoard (and others to capture your IOT data) from other howtos
emoncms/LinuxInstall.md at master · emoncms/emoncms · GitHub
A Howto install freeboard with MQTT for emontx shield
next project converting old MXQ android tv box to a armbian for my kids piano keyboard and turning sound station
http://mxqproject.com/files/MXQ-Debian-8/MXQProject-Linux-Desktop/
okay good luck have fun…