Tethering Methods with a Banana Pi M4

Jarret B

Active Member
Staff member
Credits
1,018
Tethering is a method of connecting one device to another for accessing the Internet.

With some devices which do not have an On The Go (OTG) USB Port, it can be difficult to connect to the Internet through another device.

In this article, I will use a Banana Pi M4 Single Board Computer (SBC) to connect to the Internet via tethering. The tethering will be accomplished through a laptop with Wi-Fi access to the Internet.

There are two ways which the tethering can be performed:
  1. Ethernet
  2. Bluetooth
Let’s look at both of these. The methods should work on other systems to perform tethering, but let’s look at the Banana Pi M4 first.

Banana Pi M4

SINOVOIP was founded in 2003 while GuangDong BiPai Technology became independent in 2015. GuanDong Bipai Technology is the maker of the Banana Pi boards.

There are many types of Banana Pi boards but I am using the M4 board. The M4 specs are as follows:

CPU Realtek RTD1395 ARM Cortex-A53 Quad-Core 64 Bit ARMv8
GPU Mali 470 MP4 GPU OpenGL ES 1.1/2.0
Memory 1 GB DDR4 (optional 2 GB)
Storage 8G eMMC flash onboard
MicroSD slot supports up to 256GB expansion
Network 10/100 Mbit/s Ethernet
Wi-Fi 802.11 b/g/n/AC
Bluetooth 4.2
Video Output HDMI port and multi-channel audio output support 1080P H.264 H.265 2K/4K
Audio Output 3.5mm jack and HDMI
USB ports 4 x USB 2.0 ports
1 x USB 2.0 TYPE C
Size 92x60mm (3.6x2.4 inches)

You can download the Operating System (OS) images at https://drive.google.com/drive/folders/1FTSaKpzpIGLajaLGX0KU4V-QW1mPvI2-. The file you need to download is 2019-04-16-ubuntu-18.04-mate-desktop-beta-bpi-w2-m4-sd-emmc.img.zip. The image is Ubuntu 18.04 OS with the MATE Desktop.

Use Balena Etcher or some other program to place the image you downloaded on an SD Card.

Once the Banana Pi is booted you can prepare to tether with Ethernet.

Ethernet Tethering

For this to work, you need either a network hub (network switch) and Ethernet cables or a single crossover Ethernet cable.

For this tethering, I am using my laptop with an Ethernet Port and a single crossover cable.

NOTE: A crossover cable is a special Ethernet cable that has the Receive and Transmit wires crossed. The change allows for device which is connected directly to the cable to communicate without the need of a hub or switch.

Open your Network Connections window. You can select your existing Ethernet Connection and click on the button to Edit the Connection. Select the "IPV4 Settings" tab. Change the Method to "Shared to other computers". Set the IP Address manually. If your Wi-Fi is using the network of 192.168.0.0 you can set the Ethernet Address to 10.0.0.1 with a subnet of 8. If your Wi-Fi network is using the network address of 10.0.0.0 then set the IP Address to 192.168.0.1. With either one, you use leave the Gateway blank.

Once the devices are wired you will need to set up a DHCP Service to assign an IP Address to your device that you connect to the Ethernet Port. You can install the DHCP Service with the following commands:

sudo apt update
sudo apt install isc-dhcp-server


You will then need to change the configuration file to lease out the appropriate addresses. Open a Terminal and change to the folder ‘/etc/dhcp/’. You then need to edit the configuration file with your choice of editors. Remember to use ‘sudo’ and edit the file ‘dhcpd.conf’.

If you gave your Ethernet Port the address 10.0.0.1 then paste the following into the configuration file:

subnet 10.0.0.0 netmask 255.0.0.0 {
range 10.0.0.100 10.0.0.150;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.0.0.0;
option routers 10.0.0.1;
default-lease-time 43200;
max-lease-time 86400;
}


If the IP Address you assigned to the Ethernet Port was 192.168.0.1 then paste the following:

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.150;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
option routers 192.168.0.1;
default-lease-time 43200;
max-lease-time 86400;
}


NOTE: It is imperative that the IP Addressing scheme is different for the Wi-Fi and the Ethernet port. If they are the same then the DHCP Service we are setting up will start issuing addresses to both the Wi-Fi and Ethernet networks.

Once the service is configured you can issue the following command in a Terminal to restart the service with the new configuration:

sudo service isc-dhcp-server restart

To be helpful you should also install Nmap with the command:

sudo apt install nmap

Once installed you can issue one of the following commands depending on the IP Addresses you have configured:

sudo nmap -sP 10.0.0.2254
sudo nmap -sP 192.168.0.2254

NOTE: You may need to install NMAP with the command ‘sudo apt install nmap’.

The result you get back should be the IP Address of the attached device. If for some reason it does not give you a result you may need to wait for the DHCP Service to issue an address. Try the appropriate command again.

Now that you have the IP Address of the device you use Remmina to connect to the device with the address you found previously.

NOTE: For the Banana Pi the username is ‘pi’ and the password is ‘bananapi’.

One last thing to change on the Banana Pi after you SSH into it you need to add a Nameserver. Perform the following command and add ‘nameserver 8.8.8.8’:

sudo nano /etc/resolv.conf

You can use SSH to get a Terminal and perform an update:

sudo apt update
sudo apt upgrade -y


Your device should be able to connect to the Internet through your system whether it be a Laptop or other hardware system.

When you have finished with the tether you can change the Network Connections from ‘Shared to other computers’ back to ‘Automatic (DHCP)’ or whatever it was set to before you changed it. You can also remove the DHCP Service if needed.

Bluetooth Tethering

The process of Bluetooth Tethering is not a simple one until you understand how it works. Setting up this process took a little time to get it to work properly.

According to the Bluetooth information it is possible to make a small network of 7 systems. One system acts as the ‘Manager’ while the rest are ‘Users’. The ‘Manager’ can allow access to the Internet acting as a Bridge.

To start you will need to run the following command on any Linux system which will be part of the Bluetooth Network.

sudo apt-get install bluetooth bluez bluez-tools rfkill

All of the Linux systems need to have a Bluetooth Adapter even if it is a Bluetooth dongle.

NOTE: The Bluetooth Adapters should be running similar versions such as 4.x or 5.x. Do not try to connect a lower version with a much higher version. To check the version of the Adapter you need to install the previous packages and start the Bluetooth Service (sudo /etc/init.d/bluetooth start). After the service is started you can run the command ‘hciconfig -a’ to get the Bluetooth version.

Some systems will have a Graphical User Interface (GUI) for the Bluetooth setup. If your system does not have easy access to it then you can start it from the command-line with 'blueman-manager'. It is the same for the network manager which can be started with ‘nm-connection-editor’. Either command may need to be started with Root privileges by adding ‘sudo’ in front of the command.

NOTE: It may be best to have each system connect to the other to verify that Bluetooth is compatible between them. By connecting them all one at a time you will have a list of each User in your Bluetooth Manager. Also, select each connection to the Manager from the Users and select 'Trust'. From the Manager to each User select 'Trust'. Under ‘Bluetooth Manager’ you go to ‘Adapter’ then ‘Preferences’ and click ‘Always Visible’ for all of the systems.

Select the ‘Manager’ system which should also have a connection to the Internet if needed. The 'Manager' system is where we will set up the Personal Area Network (PAN). The PAN network is the one that all PAN Users (PANU) will connect to for connectivity to one another. By default, the name will be PAN1.

On the ‘Manager’ system you need to open the ‘blueman-manager’ and then select ‘View’ and ‘Local Services...’. Once opened you can check the box to enable the ‘Network Access Point (NAP)’. Leave the DHCP Server type as ‘dnsmasq’. My system auto-assigned an address of ‘172.16.0.1’ for the PAN Bridge. Try to make the subnet unique on your network or let the system auto-assign the address. PAN Support should be set to ‘BlueMan’. The option for DUN Support should be ‘NetworkManager’

You can restart the Bluetooth service with the command ‘sudo /etc/init.d/bluetooth restart’ if the ‘pan1’ bridge does not show up in the ‘ifconfig’ command. Once the service is restarted you can then run ‘ifconfig’ and see that the PAN1 Bridge has been created as shown in Figure 1.

Figure 01.jpg

FIGURE 1

We now need to get the MAC Addresses of the Bluetooth Adapters. To get the MAC Address you need to use the command ‘hcitool dev’.

For my systems I have the following MAC Addresses:

HP Laptop (Manager) A8:6D:AA:AE:04:9C
Acer Aspire One (PANU) 00:1A:7D:DA:71:11
BananaPi (PANU) 74:EE:2A:1C:80:F5

NOTE: At any point, if a remote system should disappear and reappear you will need to make sure the devices are still set as trusted. Keeping the device trusted is VERY imperative. Trust should be set on all devices to trust all devices.

The next step will be done in a Terminal. Issue the following command on the Manager System:

sudo bt-network -d -s NAP pan1

The command is starting a daemon to act as the Manager (NAP) on the network ‘pan1’. If you do not need to bridge to the Internet then use ‘GN’ instead of ‘NAP’.

You can follow the directions for the other systems, in my case, this is the Banana Pi and the Acer. Run a Terminal and type in the following command on each User of the network.

sudo bt-network -d -s PANU pan1

Here we are making the 'client' system a Personal Area Network User. On the 'PANU' system you need to open the Bluetooth Manager. Right-click on the connection to 'Manager' and select 'Network Access Point'. The 'PANU' system should connect to the 'Manager' as a network connection using IPv4. The Manager can be accessed by the IP Address of PAN1. On each PANU run, 'ifconfig', and a virtual adapter named 'bnep0' should show the IP Address of the PANU.

If you want to control the IP Address for each device then you need to open the 'Properties' or 'Edit the selected Connection' under 'Network Connections'. Click on the 'IPv4 Settings' tab and then set the 'Method' to 'Manual'. Click on 'Add' and then enter an IP Address on the same subnet as PAN1. The Netmask should be '24' and the Gateway will be the value of PAN1.

Under the ‘nm-applet’ you can left-click and a list of network connections should be shown. Here you should see a new section of ‘Mobile Devices’ or ‘Bluetooth Devices’. Select the Bluetooth name of the ‘Manager’ system and you should connect.

Under extreme issues of connecting make sure the 'Manager' trusts the 'User' and the 'User' trusts the 'Manager' under the 'blueman-manager'. Also, be sure that you ran the command 'sudo bt-network -d -s panu pan1' in a Terminal on the 'User'.

You can perform these tasks for up to seven systems to make a single network. The ‘User’ system should be able to reach the Internet through the ‘Manager’ device as long as it can reach the Internet.
I will admit that the Bluetooth Tethering is a bit of touch-and-go until the tethering is completed. Do not give up on it because it does work. Some Desktop Environments may be a little different. I found the best result with Cinnamon.

Conclusion

Tethering can be beneficial not only for SBC boards but any Linux system. Knowing the various methods for tethering can give you a broader availability of resources to use to create the tether.

Using these methods can also allow you to create a small network of systems for gaming or some other purpose. For Internet access, these methods can share a single resource to many systems.

It may not seem too advantageous to use these methods, but realize that they do exist and do work.
 


Members online


Latest posts

Top