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

Source: Internet
Author: User

http://wangye.org/blog/archives/845/

Recently began to toss up Raspberry Pi came, because somewhere in the internet need Ruijie dialing, so I would like to be able to let my Raspberry Pi do, of course, first of all to transform it into a router, the default comes with the network as a WAN port, we also lack a network port, Wood has a way, had to occupy a USB port, Connected to a USB card, the network of USB to RJ45 network cable adapter Less, the price is not cheap, so consider simply transform it into a no-line, but also in line with the current high-end atmosphere grade standards.

Preparation work, of course, first to buy a USB wireless network card, you can buy more models, Raspberry PI official also provides a compatibility list for your reference, specific punch here. I'm buying a network (Netgear) wna1000m 150M mini USB wireless card .

The more official introduction of the wireless Hotspot configuration is the article "Rpi-wireless-hotspot". However, the actual configuration will never succeed. However, the wireless network card can be recognized, through lsusb and lsmod check see, but I noticed that this wireless chip model is Realtek Rtl8188cus, the initial suspicion is the driver problem.

Of course, see someone else's old wireless network card has been configured successfully in the heart unavoidably itch, of course, also can not waste money to buy a network card, so had to find their own, but despair, in the N-time brush machine reload system, finally found a successful approach, in fact, the key article on the above article in a link in the Turn Your Raspberry Pi into a WiFi Hotspot with Edimax Nano USB Ew-7811un (Rtl8188cus chipset).

Well, the following I will practice the process of recording for your reference, of course, the main reference to the above two articles , here is the memory of the configuration, I try to record the details, the omission of the point of hope points out.

1. Install the system (if the system is already installed you can skip this step)

1.1 Try to use the latest system, first download the official latest image, and then use Win32diskimager burned to the SD card. Notice here that we are using Raspbian.

1.2 Raspberry PI Connection on the wireless network card, and then the system image is brushed into the SD card, we connect the display keyboard and mouse to initialize the configuration work, of course, no conditions recommend the direct use of SSH connection Raspberry Pi, this is more convenient, because the new system by default open SSH management.

The connection information is mainly as follows:

Host Name: Raspberrypi user name: Pi secret  Code: Raspberry

If you are connecting directly to the Raspberry Pi via SSH, the following configuration steps are necessary:

1.2.1 Initialization configuration, the following configuration is only required within the newly installed system, only once.

Run the following command to enter the configuration interface:

sudo raspi-config

It is recommended to update the following configuration options ( new Configuration Interface):

1 Expand Filesystem2 Change User Password4 internationalisation Options  I1 change Locale  I2 change Timezone8 Advan CED Options  A3 Memory Split  A6 Update

( old Configuration Interface)

Updateexpand_rootfschange_passchange_timezonememory_split

Note Here Memory Split/memory_split that the default reserved for the graphical interface is 64MB, as a no-line from the basic use of the graphical interface, it is obvious that 64MB slightly extravagant, we will change it to 32MB.

Finally, the Finish initialization configuration is completed. The system automatically prompts for a restart, and if it does not restart as expected, restart the system using the following command:

-R Now

2. Install hotspot (HOSTAPD)

Apt-get Install Bridge-utils HOSTAPD

HOSTAPD implementation of wireless sharing, but it is important to note that the official program is not compatible with the Rtl8188cus chip wireless card, but the Edimax team specifically compiled a compatible version for us, the following operations need to replace HOSTAPD as a compatible version.

The following commands are replaced:

wget http:Www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zipUnzip Hostapd.zipSudoMv/usr/sbin/hostapd/usr/sbin/hostapd.bakSudoMV HOSTAPD/usr/sbin/hostapd.edimaxSudoln-sf/usr/sbin/ Hostapd.edimax /usr /sbin/ HOSTAPD sudo  Chown root.root /usr /sbin/ HOSTAPD sudo  chmod 755 /usr/sbin/HOSTAPD       

Next, there are two kinds of solutions, one is the bridge mode set hot spot, a bit like switch operation principle, the signal of the network port is converted to wireless, the other is the way to implement wireless internet, and most routers work the same way.

3. Bridging the way to set up WiFi hotspots (scenario I)

3.1 Installing the Prerequisite program

Apt-get Install Bridge-utils

3.2 Configuring the NIC

To edit the NIC configuration file:

/etc/network/interfaces 

Comment out all the parts about the wireless card, and it should end up as follows:

#allow-hotplug wlan0#wpa-roam/etc/wpa_supplicant/wpa_supplicant.conf#iface Default inet DHCP

Add the following bridging configuration:

Auto Br0iface br0 inet dhcpbridge_ports eth0 wlan0

The final configuration consists mainly of the following components:

#loopback Adapterauto loiface lo inet loopback#wired adapteriface eth0 inet dhcp#bridgeauto br0iface br0 inet dhcpbridge_p Orts eth0 Wlan0

3.3 Configuring HOSTAPD

/etc/HOSTAPD/hostapd.conf 

The configuration information is as follows:

Interface=wlan0driver=rtl871xdrvbridge=br0ssid=my_ssid_namechannel=1wmm_enabled=0wpa=1wpa_passphrase= Mypasswordwpa_key_mgmt=wpa-pskwpa_pairwise=tkiprsn_pairwise=ccmpauth_algs=1macaddr_acl=0

Configuration file specific I will not say, presumably you see the content also know the meaning of each, save this configuration file.

3.4 Restart and test HOSTAPD

sudo reboot

After the restart is complete, test it correctly using the following command:

/etc/HOSTAPD/hostapd.conf 

If there are no errors, you should be able to search for the wireless signal you have configured. Then CTRL + C exits the test.

If everything is OK, we can set the HOSTAPD configuration file path.

/etc/default/HOSTAPD 

Remove the comment symbol and change the following behavior to our configuration file path:

daemon_conf= "/etc/hostapd/hostapd.conf"

Bridge Mode configuration Complete!

4. Route the way to set up WiFi hotspots (Scenario II)

4.1 Installing the Prerequisite program

Apt-get Install UDHCPD

UDHCPD is primarily for devices connected to WiFi automatically assigned IP address, of course you can also swap with the software you are familiar with.

4.2 Configuration UDHCPD, edit /etc/udhcpd.conf , main contents are as follows:

Start 192.168.42.2 # This is the range of IPs that the Hostspot would give to client Devices.end 192.168.42.20interface WLA  N0 # The device udhcp listens on.remaining yesopt DNS 8.8.8.8 4.2.2.2 # The DNS servers client devices would use.opt subnet 255.255.255.0opt Router 192.168.42.1 # The Pi ' s IP address on wlan0 which we'll set up shortly.opt lease 864000 # ten DA Y DHCP lease time in seconds

Next edit /etc/default/udhcpd and comment out the following line to make the DHCP server work correctly:

#DHCPD_ENABLED = "No"

4.3 Configuring the Wireless Card

Set an IP address for the wireless card by using the following command:

Ifconfig Wlan0 192.168.42.1

Of course, for the next boot to work, we need to configure the /etc/network/interfaces file:

/etc/network/interfaces 

Comment out all the parts about the wireless card, and it should end up as follows:

#wpa-roam/etc/wpa_supplicant/wpa_supplicant.conf#iface Default inet DHCP

Note that the allow-hotplug wlan0 original English is not retained, but I operate to find that if you do not keep this paragraph, the wireless network card sometimes does not configure the IP, the last wireless network card IP configuration information as follows:

Allow-hotplug wlan0iface wlan0 inet static  address 192.168.42.1  netmask 255.255.255.0

4.4 Editing the HOSTAPD configuration

/etc/HOSTAPD/hostapd.conf 

The contents are as follows:

Interface=wlan0driver=rtl871xdrvssid=my_ssid_namehw_mode=gchannel=6macaddr_acl=0auth_algs=1ignore_broadcast_ ssid=0wpa=2wpa_passphrase=mypasswordwpa_key_mgmt=wpa-pskwpa_pairwise=tkiprsn_pairwise=ccmp

4.7 Turn on the IP steering function to enable NAT

"Echo 1 >/proc/sys/net/ipv4/ip_forward"

Edit /etc/sysctl.conf Change the following line:

Net.ipv4.ip_forward=1

4.8 Configuring the Iptables Firewall

sudo iptables -t nat -a postrouting -o eth0 -j masqueradesudo iptables -i eth0 -o wlan0 -m State --state related,established -j acceptsudo iptables -a FORWARD Span style= "color: #660033;" >-i wlan0 -o eth0 -j ACCEPT     

The NAT feature that has been routed here has been enabled, and the iptables we have just configured is saved for the next use:

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

Edit /etc/network/interfaces and add the following line at the end to automatically load the iptables configuration for each boot:

Up Iptables-restore </etc/iptables.ipv4.nat

4.9 Restart and test HOSTAPD

sudo reboot

After the restart is complete, test it correctly using the following command:

/etc/HOSTAPD/hostapd.conf 

If there are no errors, you should be able to search for the wireless signal you have configured. Then CTRL + C exits the test.

If everything is OK, we can set the HOSTAPD configuration file path.

/etc/default/HOSTAPD 

Remove the comment symbol and change the following behavior to our configuration file path:

daemon_conf= "/etc/hostapd/hostapd.conf"

4.10 Launch the appropriate software and join the startup item

sudo service hostapd startsudo service udhcpd startenable   Enable

December 12, 2013 update

Recently often found that the wireless network adapter configuration of the DHCP does not work, after the discovery to the wireless network card specified static IP failed, that is, the wireless network card does not have IP caused by DHCP can not be working, find this article on the Internet "Why won ' t DNSMASQ ' s DHCP server works When using HOSTAPD?, according to the content I will /etc/default/ifplugd modify the configuration as follows:

INTERFACES="eth0"hotplug_interfaces= "eth0"ARGS="-q-f-u0-d10-w-i"suspend_ ACTION="Stop"          

Restarted a few times to test, the results are normal!

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

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.