Template:OpenWrt1

From FriendlyELEC WiKi
Revision as of 10:31, 25 April 2019 by Tzs (Talk | contribs) (updated by API)

Jump to: navigation, search

1 Work with OpenWrt

1.1 Introduction

OpenWrt is a highly extensible GNU/Linux distribution for embedded devices.Unlike many other distributions for routers, OpenWrt is built from the ground up to be a full-featured, easily modifiable operating system for embedded devices. In practice, this means that you can have all the features you need with none of the bloat, powered by a modern Linux kernel. For more details you can refer to:OpenWrt Website.

1.2 System Login

  • Login via Serial Communication

For example, NanoPi-M1:
PSU-ONECOM-M1.jpg

By default you will login as root without a password. You can set your password by commanding "passwd".
R1-login
When your board loads OS for the first time the TF card's rootfs system in your board will be automatically partitioned to its max capacity:
resize_rootfs
Be patient for this process to be done.

  • Login via SSH

Make sure you connect your board to the internet and your board's eth0 is set to WAN and wlan0 is set to LAN.
Before you proceed make sure you connect your board to a master router's LAN and your board can get an IP address via DHCP.
We assume the board's (eth0) IP address is 192.168.1.163. You can login via SSH by running the following command:

$ ssh root@192.168.1.163

By default you will login as root without a password.

  • Login via Web

OpenWrt supports web login via the LuCI Web GUI. Configure your system following the steps in <Login via SSH>. In our test the board's IP address was 192.168.1.163. Type your IP address in a browser and you will be able to load the OpenWrt-LuCI page:
R1-OpenWrt-LuCI
By default you will login as root without a password. After click on "Login" you will sign in.

1.3 Connect to WiFi Hotspot from Smart Phone

  • Make sure you install a WiFi antenna on your board.
  • By default the board with OpenWrt is configured as a secondary router and its WiFi module AP6212 is set to AP mode. The default WiFi AP hotspot's name is like "OpenWrt-10:d0:7a:de:3d:92" and it doesn't have a password. You can connect a smart phone or PC to it.
  • The board's WiFi hotspot IP address falls into 192.168.2.x. Open a browser in your phone or PC, type 192.168.2.1 in the address bar and you will be able to visit the LuCI GUI:

phone_luci

  • After your phone is successfully connected to the board's WiFi hotspot, load the LuCI page, go to "Netwrok ---> Wireless" and you will see all connected devices:

openwrt_wifiap_connected

1.4 Manage Software Packages

OpenWrt has a package management utility: opkg. You can get its details by running the following command:

$ opkg
Package Manipulation:
        update                  Update list of available packages
        upgrade <pkgs>          Upgrade packages
        install <pkgs>          Install package(s)
        configure <pkgs>        Configure unpacked package(s)
        remove <pkgs|regexp>    Remove package(s)
        flag <flag> <pkgs>      Flag package(s)
         <flag>=hold|noprune|user|ok|installed|unpacked (one per invocation)
 
Informational Commands:
        list                    List available packages
        list-installed          List installed packages
        list-upgradable         List installed and upgradable packages
        list-changed-conffiles  List user modified configuration files
        files <pkg>             List files belonging to <pkg>
        search <file|regexp>    List package providing <file>
        find <regexp>           List packages whose name or description matches <regexp>
        info [pkg|regexp]       Display all info for <pkg>
        status [pkg|regexp]     Display all status for <pkg>
        download <pkg>          Download <pkg> to current directory
...

These are just part of the manual. Here are some popular opkg commands.

  • Update Package List

Before you install a package you'd better update the package list:

$ opkg update
  • Check Available Packages
$ opkg list

At the time of writing there are 3241 packages available.

  • Check Installed Packages:
$ opkg list-installed

At the time of writing 124 packages have been installed.

  • Install/Delete Packages:
$ opkg install <pkgs>
$ opkg remove <pkgs>
  • Check Files Contained in Installed Packages:
$ opkg files <pkg>
  • Install Chinese Language Package for LuCI
$ opkg install luci-i18n-base-zh-cn
  • Check Changed Files:
$ opkg list-changed-conffiles

1.5 Check System Status

  • Check CPU Temperature & Frequency:
$ cpu_freq
CPU0 online=1 temp=26581 governor=ondemand cur_freq=480000
CPU1 online=1 temp=26581 governor=ondemand cur_freq=480000
CPU2 online=1 temp=26581 governor=ondemand cur_freq=480000
CPU3 online=1 temp=26581 governor=ondemand cur_freq=480000

These messages mean four CPU cores are working online. Each core's temperature is 26.5 degrees. Each core's governor is on demand and the frequency is 480 MHz.

  • Check System Status on OpenWrt-LuCI Web Page:

After you load the OpenWrt-LuCI page, click on "Statistics ---> Graphs" and you will be able to check all the statistics:
1) System Load:
statistics_system_load
2) RAM:
statistics_memory
3) CPU Temperature:
statistics_thermal
"Statistics" is collected by the luci-app-statistics package. The luci-app-statistics package uses the Collectd utility to collect statistics and presents them using the RRDtool utility.
If you want to get more statistics you can install various collectd-mod-* packages. All collectd-mod-* packages use the same configuration file: /etc/config/luci_statistics.

1.6 Check Network->Interfaces Configurations

  • Login OpenWrt-LuCI, go to "Network ---> Interfaces" and you will see all the configurations:

R1_Interfaces
The Ethernet eth0 is configured as WAN and wlan0 is configured as LAN.

  • You can set WAN or LAN by clicking on "WAN" or "LAN".

R1_Interfaces_WAN R1_Interfaces_LAN

  • All the configurations on the Network->Interfaces page will be saved in the "/etc/config/network" file.

1.7 Check Netwrok->Wireless Configurations

  • Login OpenWrt-LuCI, go to "Network ---> Wireless" and you will see all the WiFi hotspot configurations:

R1-Wireless
By default the WiFi AP's hotspot name is like "OpenWrt-10:d0:7a:de:3d:92" without a password. You can connect a smart phone to the WiFi hotspot.

  • Click on "Edit", type a new name in Interface Configuration ---> General Setup ---> ESSID and click on Save & Apply.

R1-Wireless-ESSID

  • You can set a new encryption in Interface Configuration ---> Wireless Security, a new password in Key and click on Save & Apply.

R1-Wireless-Key

  • You can see all the connected devices in Associated Stations on the Network ---> Wireless page.

R1-Wireless-Associated Stations

  • All the configurations on the Network->Wireless page will be saved in the /etc/config/wireless file.