Set the Raspberry Pi raspberry to the wireless router (WiFi hotspot ap,rtl8188cus chip)

Source: Internet
Author: User

This article is based on the purchase of a East USB wireless network card (Rtl8188cus chip) to make wireless hotspot. Originally wanted to make a one-click script. Just record the implementation process first.

References
Turn Your Raspberry Pi into a WiFi Hotspot with Edimax Nano USB Ew-7811un (Rtl8188cus chipset)
Why won ' t DNSMASQ's DHCP server work when using HOSTAPD?

1, update the system, install the required software

We need to update the system first. Then install the necessary software to prepare for subsequent compilation of the HOSTAPD.

sudo apt-get updatesudo apt-get install bridge-utils udhcpd make libnl-dev

2. Compile and install Hostpad

The hostpad in the Git repository today is version 2.6. The latest Rtl8188cus chip has been supported, so we can compile and install it directly.

#从官网直接克隆代码git clone git://w1.fi/srv/git/hostap.git#若你想指定版本号库则能够直接checkoutgit checkout hostap_2_5cd hostap/hostapd/#使用默认配置文件cp defconfig .config#编译安装makesudo make install#这时能够看到已经将hostpad安装至`install -D hostapd /usr/local/bin//hostapd`

3.1. Bridging mode set WiFi hotspot

You can skip this step if you do not want to use a bridging method. Use router mode to set hotspots

To edit the NIC configuration file:

sudo nano /etc/network/interfaces

Then change the configuration file to such as the following configuration:

auto loiface lo inet loopbackiface eth0 inet dhcp#增加桥接auto br0iface br0 inet dhcpbridge_ports eth0 wlan0

Configuration HOSTAPD:

sudo nano /etc/hostapd/hostapd.conf

Configured to such as the following:

#macaddr_acl: Specifies the MAC address filtering rule. 0 means that unless otherwise agreed on in the list of prohibitions, 1 means unless otherwise prohibited in the consent list. 2 means using an external RADIUS server#accept_mac_file: Specify consent for Mac list file#deny_mac_file: Specifies that the Mac list file is blocked#ignore_broadcast_ssid改为1为隐藏SSID#macaddr_acl =1#accept_mac_file =/etc/hostapd/hostapd.acceptIgnore_broadcast_ssid=0Interface=wlan0Driver=rtl871xdrv#ssidSSID=my_ssid_nameHw_mode=gChannel=1Macaddr_acl=0Auth_algs=1Ignore_broadcast_ssid=0WPA=2#passwordWpa_passphrase=mypasswordWpa_key_mgmt=wpa-pskwpa_pairwise=tkiprsn_pairwise=ccmp

Then add the configuration file HOSTAPD and make it effective:

sudo nano /etc/default/hostapd

Remove the gaze symbol and fill in the path of the above configuration file under daemon_conf:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Last reboot:

sudo reboot

3.2. Set up WiFi hotspot using router mode

The main use of the UDHCPD tool is to automatically assign an IP address to a device connected to WiFi and, of course, to replace it with other DHCPD tools.

To change the UDHCPD configuration file:

sudo mv /etc/udhcpd.conf /etc/udhcpd.conf.baksudo nano /etc/udhcpd.conf

Change the configuration file to such things as the following:

#设置路由器分配的起始IP与终止IPstart192.168.42.1192.168.42.20yes#设置DNS8.8.8.84.2.2.2255.255.255.0#设置树莓派网卡的IP192.168.42.1#设置IP过期时间864000

The editor then /etc/default/udhcpd makes the DHCP server work correctly:

#将这行的凝视取消DHCPD_ENABLED="no"

Set the static IP for the Raspberry Pi wireless card:

sudo192.168.42.1

Change the NIC configuration file to make it permanent:

sudo nano /etc/network/interfaces

Change the configuration file to such things as the following:

static  192.168.42.1  255.255.255.0#每次开机自己主动载入iptablesup iptables-restore < /etc/iptables.ipv4.nat

Configuration HOSTAPD:

sudo nano /etc/hostapd/hostapd.conf

Configured to such as the following:

interface=wlan0driver=rtl871xdrv#ssidssid=My_SSID_Namehw_mode=gchannel=1macaddr_acl=0auth_algs=1ignore_broadcast_ssid=0wpa=2#passwordwpa_passphrase=MYPASSWORDwpa_key_mgmt=WPA-PSKwpa_pairwise=TKIPrsn_pairwise=CCMP

Then add the configuration file HOSTAPD and make it effective:

sudo nano /etc/default/hostapd

Remove the gaze symbol. and fill in the path of the above configuration file under daemon_conf:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Start the IP steering function to facilitate the opening of NAT:

sudo"echo 1 > /proc/sys/net/ipv4/ip_forward"

Edit sudo vim /etc/sysctl.conf Change net.ipv4.ip_forward setting to 1:

net.ipv4.ip_forward=1

Configuring the Iptable Firewall

-t-A-o-j-A-i-o-m---j-A-i-o-j ACCEPT

The NAT feature is now enabled. The contents of the current changes are then stored in the iptables configuration file:

sudo"iptables-save > /etc/iptables.ipv4.nat"

/etc/default/ifplugdchange the content to such as the following configuration:

INTERFACES="eth0"HOTPLUG_INTERFACES="eth0"ARGS="-q -f -u0 -d10 -w -I"SUSPEND_ACTION="stop"

Then start the corresponding service. and add it to the startup item:

sudo service hostapd startsudo service udhcpd startsudo update-rc.d hostapd enablesudo update-rc.d udhcpd enable

Last reboot:

sudo reboot

The configuration of the wireless hotspot is now complete. You can then connect to the password based on the SSID that you set up, and the connection is very fast after upgrading the HOSTAPD to 2.6. But there is one problem. When the channel is set to 6 o'clock, the phone connection cannot be assigned to IP.

Wait for perhaps update processing.

Set the Raspberry Pi raspberry to the wireless router (WiFi hotspot ap,rtl8188cus chip)

Related Article

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.