Difference between revisions of "Template:Linux-Create-WiFiAP"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
Line 21: Line 21:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo apt-get update
 
sudo apt-get update
sudo apt-get install hostapd git
+
sudo apt-get install -y git bash util-linux procps hostapd iproute2 iw wireless-tools haveged dnsmasq iptables
 
</syntaxhighlight>
 
</syntaxhighlight>
 
If you are using the lite version of the firmware (e.g. FriendlyCore-Lite), it is also recommended to install network-manager, otherwise you will need to manually turn on the wireless interface, as by default it will be in down state.:<br />
 
If you are using the lite version of the firmware (e.g. FriendlyCore-Lite), it is also recommended to install network-manager, otherwise you will need to manually turn on the wireless interface, as by default it will be in down state.:<br />
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo apt-get install network-manager
+
sudo apt-get -y install network-manager
 
</syntaxhighlight>
 
</syntaxhighlight>
 
Install the create_ap tool:<br />
 
Install the create_ap tool:<br />
Line 35: Line 35:
 
Make sure the wlan interface is in up state:<br />
 
Make sure the wlan interface is in up state:<br />
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
iwconfig wlan0 up
+
sudo ifconfig wlan0 up
 
</syntaxhighlight>
 
</syntaxhighlight>
 
====Set up access point====
 
====Set up access point====
Line 66: Line 66:
 
sudo create_ap --config /etc/create_ap.conf
 
sudo create_ap --config /etc/create_ap.conf
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
<!--
 
=====Wireless Bridging (This function only supports wireless mode AP6356S)=====
 
=====Wireless Bridging (This function only supports wireless mode AP6356S)=====
 
In this mode, the board can connect to the router and still create access point to be connected by other devices.
 
In this mode, the board can connect to the router and still create access point to be connected by other devices.
Line 72: Line 73:
 
sudo iw dev wlan0 interface add wlan1 type station
 
sudo iw dev wlan0 interface add wlan1 type station
 
</syntaxhighlight>
 
</syntaxhighlight>
Connect to the wireless router(STA mode):
+
Connect to your wireless router (STA mode) and remember to change the following MyHomeWiFi and 12345678 to the real hotspot name and password:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo nmcli dev wifi connect "MyHomeWiFi" password "12345678"
 
sudo nmcli dev wifi connect "MyHomeWiFi" password "12345678"
Line 80: Line 81:
 
. /etc/friendlyelec-release
 
. /etc/friendlyelec-release
 
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" \
 
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" \
   --driver nl80211 -w 2  wlan0 wlan0 ${BOARD_NAME} 12345678 --no-haveged \
+
   --driver nl80211 -w 2  wlan1 wlan0 ${BOARD_NAME} 12345678 --no-virt --no-haveged \
 
   --mkconfig /etc/create_ap.conf
 
   --mkconfig /etc/create_ap.conf
 
sudo create_ap --config /etc/create_ap.conf
 
sudo create_ap --config /etc/create_ap.conf
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
-->
 
====Set the wireless access point to be enabled automatically on boot====
 
====Set the wireless access point to be enabled automatically on boot====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">

Latest revision as of 08:18, 3 September 2021

1 Access Point Setup Guide

1.1 Compatible development boards and systems

At the time of writing this guide, the following development boards and systems were tested. Although this is not a complete list, theoretically they should work as long as the wireless modules are of the same type:

1.1.1 RK3399
  • NanoPi M4 (Wireless module:AP6356S)
  • NanoPi M4B (Wireless module:AP6256)
  • NanoPC T4 (Wireless module:AP6356S)
1.1.2 S5P4418/S5P6818
  • NanoPC T3 (Wireless module:AP6212)
  • NanoPC T2 (Wireless module:AP6212)
1.1.3 Allwinner H3/H5
  • NanoPi-M1-Plus (Wireless module:AP6212)
1.1.4 OS

The following distributions are supported :

  • FriendlyCore Focal (20.04)
  • FriendlyCore Bionic (18.04)
  • FriendlyCore Xenial (16.04)
  • FriendlyDesktop (18.04)

1.2 Installing the necessary tools

Execute the following command to install the necessary packages:

sudo apt-get update
sudo apt-get install -y git bash util-linux procps hostapd iproute2 iw wireless-tools haveged dnsmasq iptables

If you are using the lite version of the firmware (e.g. FriendlyCore-Lite), it is also recommended to install network-manager, otherwise you will need to manually turn on the wireless interface, as by default it will be in down state.:

sudo apt-get -y install network-manager

Install the create_ap tool:

git clone https://github.com/friendlyarm/create_ap.git
cd create_ap
make install

Make sure the wlan interface is in up state:

sudo ifconfig wlan0 up

1.3 Set up access point

Note: In the following description, the access point name is the model name of the development board obtained from the /etc/friendlyelec-release file, and 12345678 is the password of the access point.

1.3.1 Bridging Mode

The device connected to this AP will be in the same network segment as eth0 (the device is assigned an IP address by the router to which eth0 is connected, if the router has dhcp enabled):

. /etc/friendlyelec-release
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" \
   --driver nl80211 -w 2  -m bridge wlan0 eth0 ${BOARD_NAME} 12345678 --no-virt \
   --no-haveged --mkconfig /etc/create_ap.conf
sudo create_ap --config /etc/create_ap.conf
1.3.2 Routing Mode

The device connected to this AP is on a different subnet than eth0 (the device is assigned an ip address by the dhcp server running on the development board):

. /etc/friendlyelec-release
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" \
   --driver nl80211 -w 2  wlan0 eth0 ${BOARD_NAME} 12345678 --no-virt --no-haveged \
   --mkconfig /etc/create_ap.conf
sudo create_ap --config /etc/create_ap.conf
1.3.3 Routing Mode (Network Isolation)

Much the same as Routing Mode, but the difference is that the devices connected to this AP are not accessible to each other:

. /etc/friendlyelec-release
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" \
   --driver nl80211 -w 2  --isolate-clients wlan0 eth0  ${BOARD_NAME} 12345678 \
   --no-virt --no-haveged --mkconfig /etc/create_ap.conf
sudo create_ap --config /etc/create_ap.conf

1.4 Set the wireless access point to be enabled automatically on boot

systemctl enable create_ap
sudo reboot