In December 2017, I created a home router based Linux piCore installed on Raspberry PI3. I use this router in everyday life in order to provide Internet connection for my home devices. So far I have not noticed any issues. However, the router offers only basic functionality. The number of packages that extends router's functionality is limited by the number of available PiCore extensions in repository. Therefore, it is better to load Raspberry with a advanced network distribution that provides a better customization of embedded netwrok devices with many available packages.
The article discusses an installation and configuration of Linux Embedded Development Environment (LEDE) on Raspberry PI3. LEDE is an opensource project that was created in 2016 as a fork of OpenWrt - Linux OS for embedded devices. In 2018, LEDE and OpenWrt projects reemerged and they announced their unification under OpenWrt name .
1. LEDE Installation
The part 1 discusses installation of LEDE on Raspberry Pi3 and resizing LEDE image. After copying LEDE to SD card, we need to resize file system in order to use full capacity of SD card.
1.1 Downloading and Extracting LEDE for Raspberry PI3
$ wget https://downloads.lede-project.org/releases/17.01.4/targets/brcm2708/bcm2710/lede-17.01.4-brcm2708-bcm2710-rpi-3-ext4-sdcard.img.gz
$ gzip -d lede-17.01.4-brcm2708-bcm2710-rpi-3-ext4-sdcard.img.gz
Copy LEDE image to SD card.
$ sudo dd bs=4M if=lede-17.01.4-brcm2708-bcm2710-rpi-3-ext4-sdcard.img of=/dev/mmcblk0 status=progress conv=fsync
1.2 Resizing Root Partition
We will recreate the root partition using an original start sector before writing the data to the disk. As a result, we do not erase the existing data from the root partition. Type the command below as a root.
# fdisk /dev/mmblck0
Press ''p' Write down Start sector for the second partition. In our case, it is 57344 (Picture 1).
Picture 1 - Partition mmcblk0p2 Before Resizing
- Press 'd' to delete root partition and choose 2
- Create a new partition with 'n' and choose 2
- Press 'p' for primary and '2' for the second partition
- Enter the first sector - 57344
- Press Enter for the default end sector
- Save changes with 'w'
Expand a file system to the new partition boundaries typing the command below as root.
# sudo resize2fs /dev/mmcblk0p2
Picture 2 - Partition mmcblk0p2 After Resizing
2. LEDE Configuration
Once the LEDE boots up, hit Enter and you will get to root shell. Below is a network topology with LEDE running on Raspberry, in the middle.
Picture 3 - LEDE Raspberry PI3 Router Connected in Home Network
LEDE default configuration is stored in the relevant files below:
/etc/config/network
/etc/config/wireless
/ect/config/dhcp
/etc/config/system
You can edit these files manually or you can use uci tool. When uci is used, configuration changes are stored in temporary files. For this reason, we must commit changes with the command below. Once command is entered, changes are copied to particular configuration files stored in /ect/config directory.
uci commit
Uci can be also used for configuration checking. For instance, to check DHCP configuration, enter the command:
uci show dhcp
2.1 LEDE Configuration Using Uci
Below are the commands that configure LEDE to operate as an IPv4 Wifi router using PPoE to connect to the Internet. Router's clients are connected using Wireless network. A network adapter 10/100Mbps is connected to the ISP device. Change appropriate credentials such as PPoE login and password, wireless key and others and copy the commands below to LEDE CLI.
# Upgrade all packages that can be upgraded
opkg update
opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade
# Enable wireless interface wlan0 and configure wireless network parameters.
uci delete wireless.radio0.disabled
uci set wireless.@wifi-iface[0].ssid="lede"
uci set wireless.@wifi-iface[0].encryption=psk2
uci set wireless.@wifi-iface[0].key="raspberry"
# Assign static IP address to lan interface 192.168.230.1/24
uci set network.lan.ipaddr=192.168.230.1
uci set network.lan.ifname=wlan0
uci set network.lan.netmask=255.255.255.0
uci set network.lan.proto=static
uci set network.lan.proto=dhcp
# Configure WAN Interface and PPoE parameters
uci set network.wan=interface
uci set network.wan.ifname=eth0
uci set network.wan.proto=pppoe
uci set network.wan.username='yourusername@something'
uci set network.wan.password='yourpassword'
# Change DHCP settings
uci set dhcp.lan.start=100
uci set dhcp.lan.limit=250
uci set dhcp.lan.leasetime=24
uci set dhcp.lan.dhcp_option='6,192.168.230.1' # DHCP server IP for clients
uci set dhcp.@dnsmasq[0].server='8.8.8.8, 8.8.4.4' # upstream DNS server
# Set timezone
uci set system.system.@system[0].timezone='UTC+1'
# Install Luci (GUI)
opkg update
opkg install luci
# Install DDNS client and configure service using free DDNS provider dynu.com
opkg update
opkg install ddns-scripts
uci set dns.dynu=service
uci set ddns.dynu.enabled='1'
uci set ddns.dynu.lookup_host='dynu.com'
uci set ddns.dynu.interface='wan'
uci set ddns.dynu.ip_source='network'
uci set ddns.dynu.ip_network='wan'
uci set ddns.dynu.username='yourusername'
uci set ddns.dynu.password='yourpassword'
uci set ddns.dynu.domain='something.dynu.net'
uci set ddns.dynu.update_url='http://api.dynu.com/nic/update?hostname=something.dynu.net&username=yourhostname&password=yourpassword
#Change password for user root
passwd root
# Write changes that we made from temporary configuration files to configuration files and reload
uci commit
reload_config
reboot
2.2 Backup LEDE Image
Remove SD card and backup your new LEDE image with the command:
$ sudo dd bs=4M if=/dev/mmcblk0 of=lede.img status=progress conv=fsync
3. Testing
The picture 4 depicts achieved network bandwidth, measured by a client connected to the Internet, using LEDE running on Raspberry Pi3 B router.
Picture 4 -Network Statistics Achieved by LEDE on Raspberry Pi3 B
End.