Welcome to Raspberry Pi 4B repository
3.3 Configured as a router
The Raspberry Pi 4B has a wireless network adapter on the board that can be turned into a wireless router without the need for an additional wireless network card. The method we use here is to enable the AP function of the Raspberry Pi wireless network adapter and share its wired network.
The following describes how to enable the AP function of the Raspberry Pi wireless network adapter, and boot automatically to implement wireless routing.
This time we need to download the create_ap project on github and use this project to open the AP mode of the Raspberry Pi.
1.Install creat_ap
1.1 Download create_ap
We need to enter the command shown below at the command terminal to switch directory to pi user:
cd /home/pi
We need to enter the command shown below at the command terminal to download:
git clone https://github.com/oblique/create_ap
Enter the command shown below at the command terminal to view files in the current folder
cd create_ap
ls
1.2 Install create_ap
Enter the command shown below at the command terminal:
sudo make install
Enter the command shown below at the command terminal:
sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq
Note: Before creating a WiFi hotspot, we need to make sure the Raspberry Pi has turned on the WiFi settings and is not connected to any WiFi signals. We need to insert a network cable that can be accessed online.
1.3 Test created Wifi hotspot
sudo create_ap wlan0 eth0 name of WiFi hotspot password
For example : sudo create_ap wlan0 eth0 YahboomPiWiFi 12345678
When you turn on the phone. You can search for the YahboomPiWiFi WiFi signal the password is 12345678.
2. Setting Boot self-start AP mode
2.1 We need to create a script
nano startAP.sh
We need to input the command shown below:
#!/bin/sh
sudo create_ap wlan0 eth0 YahboomPiWiFi 12345678
We need to input the command shown below to add permissions to script files
sudo chmod 777 startAP.sh
2.2 Create a new .desktop shortcut startup file
Enter ./config file
cd /home/pi/./config
Create a new autostart folder, ignore this step if you already have it.
mkdir autostart
Enter autostart file:
cd autostart
Create self-starting shortcut:
nano startAP.desktop
Then enter the following:
[Desktop Entry]
Type=Application
Exec=/home/pi/startAP.sh
After the modification is completed, press ctrl+x, “y”, “enter” to save and exit the file.
Exec = the path to the startup script.
3. We can restart the Raspberry Pi and see the actual effect:
Input the command shown below:
sudo reboot