Open main menu

Wiki-Orange Pi β

AP6275P PCIe NIC creates WIFI hotspot via create ap

Revision as of 20:27, 24 April 2023 by Admin (talk | contribs)
create_ap is a script that helps quickly create WIFI hotspots on Linux, and supports bridge and NAT modes. It can automatically combine hostapd, dnsmasq and iptables to complete the setting of WIFI hotspots, avoiding complex configuration for users. The github address is as follows:

https://github.com/oblique/create_ap

If you using the latest image, the create_ap script has been pre-installed, and you can create a WIFI hotspot through the create_ap command. The basic command format of create_ap is as follows:

create_ap [options] <wifi-interface> [<interface-with-internet>]
[<access-point-name> [<passphrase>]]

1.create_ap method to create WIFI hotspot in NAT mode

1) Enter the following command to create a WIFI hotspot named orangepi and password orangepi in NAT mode

orangepi@orangepi5:~$ sudo create_ap -m nat wlan0 eth0 orangepi orangepi

2) If the following information is output, it means that the WIFI hotspot is created successfully

orangepi@orangepi5:~$ sudo create_ap -m nat wlan0 eth0 orangepi orangepi

Config dir: /tmp/create_ap.wlan0.conf.fPItFUJ2 PID: 3831
Network Manager found, set ap0 as unmanaged device... DONE
Creating a virtual WiFi interface... ap0 created.
Sharing Internet using method: nat
hostapd command-line interface: hostapd_cli -p
/tmp/create_ap.wlan0.conf.fPItFUJ2/hostapd_ctrl
ap0: interface state UNINITIALIZED->ENABLED

3) Take out the mobile phone at this time, in the searched WIFI list, you can find the WIFI hotspot named orangepi created by the development board, and then click orangepi to connect to the hotspot, the password is the orangepi set above

Pi-5-details-pic95.png

4) After the connection is successful, the display is as shown in the figure below

Pi-5-details-pic96.png

5) In NAT mode, the wireless device connected to the hotspot of the development board requests an IP address from the DHCP service of the development board, so there will be two different network segments, for example, the IP of the development board is 192.168.1.X

orangepi@orangepi5:~$ ifconfig eth0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.150 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::938f:8776:5783:afa2 prefixlen 64 scopeid 0x20<link>
ether 4a:a0:c8:25:42:82 txqueuelen 1000 (Ethernet)
RX packets 25370 bytes 2709590 (2.7 MB)
RX errors 0 dropped 50 overruns 0 frame 0
TX packets 3798 bytes 1519493 (1.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 83

By default, the DHCP service of the development board will assign an IP address of 192.168.12.0/24 to the device connected to the hotspot. At this time, click on the connected WIFI hotspot orangepi, and then you can see that the IP address of the mobile phone is 192.168.12.X

Pi-5-details-pic97.png

Pi-5-details-pic98.png

6) If you want to specify a different network segment for the connected device, you can specify it through the -g parameter, such as specifying the network segment of the access point AP through the -g parameter as 192.168.2.1

orangepi@orangepi5:~$ sudo create_ap -m nat wlan0 eth0 orangepi orangepi -g 192.168.2.1

At this time, after connecting to the hotspot through the mobile phone, click the connected WIFI hotspot orangepi, and then you can see that the IP address of the mobile phone is 192.168.2.X

Pi-5-details-pic99.png

Pi-5-details-pic100.png

7) If the --freq-band parameter is not specified, the hotspot created by default is in the 2.4G frequency band. If you want to create a hotspot in the 5G frequency band, you can specify it through the --freq-band 5 parameter. The specific command is as follows

orangepi@orangepi:~$ sudo create_ap -m nat wlan0 eth0 orangepi orangepi --freq-band 5

8) If you need to hide the SSID, you can specify the --hidden parameter, the specific command is as follows

orangepi@orangepi:~$ sudo create_ap -m nat wlan0 eth0 orangepi orangepi --hidden

At this time, the mobile phone cannot search for the WIFI hotspot. You need to manually specify the name of the WIFI hotspot and enter the password to connect to the WIFI hotspot

Pi-5-details-pic101.png

2.create_ap method to create WIFI hotspot in bridge mode

1) Enter the following command to create a WIFI hotspot named orangepi and password orangepi in bridge mode

orangepi@orangepi:~$ sudo create_ap -m bridge wlan0 eth0 orangepi orangepi

2) If the following information is output, it means that the WIFI hotspot is created successfully

orangepi@orangepi:~$ sudo create_ap -m bridge wlan0 eth0 orangepi orangepi

[sudo] password for orangepi:
Config dir: /tmp/create_ap.wlan0.conf.fg9U5Xgt
PID: 3141
Network Manager found, set ap0 as unmanaged device... DONE
Creating a virtual WiFi interface... ap0 created.
Sharing Internet using method: bridge
Create a bridge interface... br0 created.
hostapd command-line interface: hostapd_cli -p
/tmp/create_ap.wlan0.conf.fg9U5Xgt/hostapd_ctrl
ap0: interface state UNINITIALIZED->ENABLED ap0: AP-ENABLED

3) Take out the mobile phone at this time, and you can find the WIFI hotspot named orangepi created by the development board in the searched WIFI list, and then you can click orangepi to connect to the hotspot, and the password is the orangepi set above

Pi-5-details-pic102.png

4) After the connection is successful, the display is as shown in the figure below

Pi-5-details-pic103.png

5) In bridge mode, the wireless device connected to the hotspot of the development board also requests an IP address from the DHCP service of the main router (the router connected to the development board), for example, the IP of the development board is 192.168.1.X

orangepi@orangepi:~$ ifconfig eth0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.150 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::938f:8776:5783:afa2 prefixlen 64 scopeid 0x20<link>
ether 4a:a0:c8:25:42:82 txqueuelen 1000 (Ethernet)
RX packets 25370 bytes 2709590 (2.7 MB)
RX errors 0 dropped 50 overruns 0 frame 0
TX packets 3798 bytes 1519493 (1.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 83

The IP of the device connected to the WIFI hotspot is also assigned by the main router, so the mobile phone connected to the WIFI hotspot and the development board are in the same network segment. At this time, click on the connected WIFI hotspot orangepi, and then you can see the IP address of the mobile phone Also 192.168.1.X

Pi-5-details-pic104.png

Pi-5-details-pic105.png

6) If the --freq-band parameter is not specified, the hotspot created by default is in the 2.4G frequency band. If you want to create a hotspot in the 5G frequency band, you can specify the --freq-band 5 parameter. The specific command is as follows

orangepi@orangepi:~$ sudo create_ap -m bridge wlan0 eth0 orangepi orangepi --freq-band 5

7) If you need to hide the SSID, you can specify the --hidden parameter, the specific command is as follows

orangepi@orangepi:~$ sudo create_ap -m bridge wlan0 eth0 orangepi orangepi --hidden

At this time, the mobile phone cannot search for the WIFI hotspot. You need to manually specify the name of the WIFI hotspot and enter the password to connect to the WIFI hotspot.

Pi-5-details-pic106.png