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

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
===设置WiFi热点(命令行方式)===
+
===Access Point Setup Guide===
====支持的开发板与系统====
+
====Compatible development boards and systems====
本部分内容仅适用于以下开发板:<br />
+
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:<br />
NanoPi M4<br />
+
=====RK3399=====
NanoPC T4<br />
+
* NanoPi M4 (Wireless module:AP6356S)<br />
支持以下Linux系统:<br />
+
* NanoPi M4B (Wireless module:AP6256)<br />
FriendlyCore<br />
+
* NanoPC T4 (Wireless module:AP6356S)<br />
FriendlyDesktop<br />
+
=====S5P4418/S5P6818=====
====安装工具====
+
* NanoPC T3 (Wireless module:AP6212)<br />
在开发板的Linux系统下执行以下命令:<br />
+
* NanoPC T2 (Wireless module:AP6212)<br />
 +
=====Allwinner H3/H5=====
 +
* NanoPi-M1-Plus (Wireless module:AP6212)<br />
 +
=====OS=====
 +
The following distributions are supported :<br />
 +
* FriendlyCore Focal (20.04)<br />
 +
* FriendlyCore Bionic (18.04)<br />
 +
* FriendlyCore Xenial (16.04)<br />
 +
* FriendlyDesktop (18.04)<br />
 +
====Installing the necessary tools====
 +
Execute the following command to install the necessary packages:<br />
 +
<syntaxhighlight lang="bash">
 +
sudo apt-get update
 +
sudo apt-get install -y git bash util-linux procps hostapd iproute2 iw wireless-tools haveged dnsmasq iptables
 +
</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 />
 +
<syntaxhighlight lang="bash">
 +
sudo apt-get -y install network-manager
 +
</syntaxhighlight>
 +
Install the create_ap tool:<br />
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/create_ap.git
 
git clone https://github.com/friendlyarm/create_ap.git
Line 14: Line 33:
 
make install
 
make install
 
</syntaxhighlight>
 
</syntaxhighlight>
====设置WiFi热点====
+
Make sure the wlan interface is in up state:<br />
=====桥接模式=====
+
<syntaxhighlight lang="bash">
连接到此AP的设备,会与eth0处于同一网段 (设备由eth0所连接的路由器分配ip地址,如果路由器开启了dhcp的话)
+
sudo ifconfig wlan0 up
 +
</syntaxhighlight>
 +
====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.<br />
 +
=====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):
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" --driver nl80211 -w 2  -m bridge wlan0 eth0 nanopct4 12345678 --no-virt --no-haveged --mkconfig /etc/create_ap.conf
+
. /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
 
sudo create_ap --config /etc/create_ap.conf
 
</syntaxhighlight>
 
</syntaxhighlight>
=====NAT有线网络=====
+
=====Routing Mode=====
连接到此AP的设备,与eth0处于不同的子网 (设备由开发板端运行的dhcp server分配ip地址):
+
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):
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" --driver nl80211 -w 2  wlan0 eth0 nanopct4 12345678 --no-virt --no-haveged --mkconfig /etc/create_ap.conf
+
. /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
 
sudo create_ap --config /etc/create_ap.conf
 
</syntaxhighlight>
 
</syntaxhighlight>
=====AP隔离模式=====
+
=====Routing Mode (Network Isolation)=====
与NAT有线网络大致相同,但区别是连接到此AP的设备,相互之间无法访问:
+
Much the same as Routing Mode, but the difference is that the devices connected to this AP are not accessible to each other:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" --driver nl80211 -w 2  --isolate-clients wlan0 eth0  nanopct4 12345678 --no-virt --no-haveged --mkconfig /etc/create_ap.conf
+
. /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
 
sudo create_ap --config /etc/create_ap.conf
 
</syntaxhighlight>
 
</syntaxhighlight>
=====AP模式与STA模式共存=====
+
<!--
在此模式下,开发板可以连接到路由器,仍然可以创建热点被其他设备连接。
+
=====Wireless Bridging (This function only supports wireless mode AP6356S)=====
先创建一个虚拟接口 wlan1:
+
In this mode, the board can connect to the router and still create access point to be connected by other devices.
 +
Create a virtual interface wlan1:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
sudo iw dev wlan0 interface add wlan1 type station
 
sudo iw dev wlan0 interface add wlan1 type station
 
</syntaxhighlight>
 
</syntaxhighlight>
连接到无线路由(STA模式):
+
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"
 
</syntaxhighlight>
 
</syntaxhighlight>
创建WiFi热点(AP模式):
+
Create Wireless access point (AP Mode):
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" --driver nl80211 -w 2  wlan0 wlan0 nanopct4 12345678 --no-haveged --mkconfig /etc/create_ap.conf
+
. /etc/friendlyelec-release
 +
sudo create_ap --country CN --ieee80211n --ht_capab "[DSSS_CK-40][HT20+]" \
 +
  --driver nl80211 -w 2  wlan1 wlan0 ${BOARD_NAME} 12345678 --no-virt --no-haveged \
 +
  --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====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
systemctl enable create_ap
 
systemctl enable create_ap
 
sudo reboot
 
sudo reboot
 
</syntaxhighlight>
 
</syntaxhighlight>
===设置WiFi热点(FriendlyDesktop界面)===
 
TODO
 

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