Raspberry School Notes--wifi AP hotspot mode using rt5370__ raspberry pie

Source: Internet
Author: User
Tags iptables

0. Foreword

This article details the steps to add WiFi AP hotspot functionality to the raspberry pie. After the configuration is complete, the raspberry pie will add a WiFi hotspot feature, using a laptop or mobile phone to connect to the raspberry pie, the raspberry pie has the AP hotspot feature to further expand the raspberry-related web function by connecting the hotspot provided by the raspberry pie, and logging on to the Web service provided by the raspberry pie,     To get information about what the raspberry faction is monitoring.     There are more steps to configure, please remain patient.     "Configuration Notes" 1. Raspberry pie hotspot Name (SSID) is raspberry_ap, the hotspot password is 12345678, the encryption method is WPA2.     2. The IP address of the raspberry-sent wireless network is 192.168.0.1.     3. Raspberry-Sent wireless network port has simple DHCP function.     4. The Raspberry faction has the forwarding function between the wireless network port and the wired network port.     For more information, see the "Raspberry School Notes-Index Blog" "Raspberry School notes--USB WiFi Configuration Guide"-describes the STA mode configuration steps, which this article is AP mode. "Raspberry School Notes--Modify the raspberry-pie software source."
1. Choose the right USB WiFi network cardPlease purchase the appropriate USB WiFi wireless card first. Taobao is the easiest to buy for the raspberry Pie USB wireless card for the Edup Ep-n8508gs, the USB wireless card chip for the Realtek 8188. In the default drive provided by the Raspbian system, REALTEK 8188 does not work directly in WiFi AP mode.     To be able to use WiFi AP mode in the Raspberry Pie Raspbian system, you can purchase a USB WiFi card with a network card chip of RT5730 or RT5732, such as sl-1506n.     Plug the USB WiFi into the raspberry-pie USB port and log on to the raspberry pie. "Use the LSUSB command" If USB WiFi is plugged in correctly, you can view the RT5370 related information.
Figure 1.1 View RT5370 Related information "Install IW tool" sudo apt-get install IW "View wireless list using IW command" IW list if you use a RT5370 network card to get more information , the following figure prints the content in the IW List command section.
Figure 1.2 IW list related information if you use the RTL8188 network card, the IW List command outputs only "nl80211 not found", which means that RTL8188 does not support AP mode in this system.
2. Necessary preparatory work"1" Update software source sudo apt-get update "2" Install the necessary software sudo apt-get install HOSTAPD UDHCPD HOSTAPD is a user-state daemon for AP and authentication servers, which implements IEEE 802 .11 Related access Management (from Baidu Encyclopedia). UDHCPD enables the raspberry pie to have DHCP server capabilities.
3. Configure DHCP featuresThe configuration file is located in/etc/udhcpd.conf, which is divided into three steps. sudo nano/etc/udhcpd.conf "1" modifies the network interface interface eth0 to interface Wlan0
Figure 3.1 Modifying Udhcpd.conf "2" before removing remaining # #remaining Yes to remain yes
Figure 3.2 Modify udhcpd.conf "3" Modify raspberry IP address modify opt router is 192.168.0.1, then the configuration is complete after the RASPBERRY Send AP mode IP address for 192.168.0.1 here opt DNS was modified to Jiangsu Telecom's common DNS address 211.228.255.1 and 218.2.135.1.
Figure 3.3 Modifying udhcpd.conf
4. Enable DHCPConfigure/ETC/DEFAULT/UDHCPD sudo nano/etc/default/udhcpd use the # symbol annotation dhcpd_enabled= "No" dhcpd_enabled= "no" to #DHCPD_ENABLED = " No
Figure 4.1 Modifying UDHCPD
5. Configure the Wlan0 as a static IP addressThe following instructions are entered directly through the console, and the Wlan0 IP address corresponds to the relevant configuration parameters in/etc/udhcpd.conf. sudo ifconfig wlan0 192.168.0.1
6. Configure the network card startup parametersProfile/etc/network/interfaces, note that wlan0 address parameters here correspond to etc/udhcpd.conf related parameters. sudo nano/etc/network/interfaces annotation #allow-hotplug wlan0 #iface wlan0 inet manual #wpa-roam/etc/wpa_supplicant/wpa_supp licant.conf #iface Default inet dhcp add iface wlan0 inet static address 192.168.0.1 netmask
Figure 6.1 Modifying interfaces
7. Configure AP ParametersSet parameters to create a file/etc/hostapd/hostapd.conf, configure the Raspberry AP hotspot name and hotspot password. sudo nano/etc/hostapd/hostapd.conf adds the following content to the file interface=wlan0 driver=nl80211 ssid=raspberry_ap hw_mode=g channel=6 Macaddr_acl=0 Auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=12345678 Wpa_key_mgmt=WPA-PSK TKIP rsn_pairwise=ccmp
Where Interface=wlan0, specify the NIC name as Wlan0. wpa=2, using WPA2 encryption method. Ssid= Raspberry_ap is a hotspot name and can be modified according to the actual situation.     Wpa_passphrase= 12345678 for the hotspot password, can be modified according to the actual situation, if the use of WPA2 encryption, the length of the password should be not less than 8 characters. "Specify profile Location" Modify configuration file/etc/default/hostapd sudo nano/etc/default/hostapd #DAEMON_CONF = "" For daemon_conf= "/etc/hostapd/ Hostapd.conf "
Figure 7.1 Modifying HOSTAPD
8. Configure NAT (IP forwarding)"1" Linux kernel start IP forwarding sudo sh-c "echo 1 >/proc/sys/net/ipv4/ip_forward" Modify/etc/sysctl.conf file sudo nano/etc/sysctl.conf Add net.ipv4.ip_forward=1 to the last line of the file
Figure 8.1 Modify Sysctl.conf "2" to define IP forwarding rules in turn, enter the following command sudo iptables-t nat-a postrouting-o eth0-j Masquerade sudo iptables-a D-i Eth0-o wlan0-m The state--state related,established-j ACCEPT sudo iptables-a forward-i wlan0-o eth0-j ACCEPT "3" security Save modify sudo sh-c "Iptables-save >/etc/iptables.ipv4.nat" "4" again modify/etc/network/interfaces file/etc/network/interfaces last Line add sudo nano/etc/network/interfaces add up Iptables-restore </etc/iptables.ipv4.nat
Figure 8.2 Modifying interfaces again
9. Start Service"1" Start HOSTAPD and UDHCPD Services sudo service HOSTAPD start sudo service udhcpd start "2" Set boot up sudo update-rc.d HOSTAPD Enable sudo update-rc.d UDHCPD enable
10. Basic VerificationIf all the configuration is successful, then you can find the SSID for Raspberry_ap hotspot, the hotspot password is 12345678, the hotspot IP address is 192.168 0.1, the notebook is assigned an IP address of 192.168.0.63.
Figure 10.1 Basic validation
reference materials"1" rpi-wireless-hotspot "2" sets the raspberry Raspberry Pi to wireless router (WiFi hotspot ap,rtl8188cus chip) "3" HOSTAPD WiFi hotspot (AP)



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.