Rpi-wireless-hotspot

Source: Internet
Author: User

Http://elinux.org/RPI-Wireless-HotspotWhat does it does?

This project configures your Raspberry Pi to connect to the Internet through Ethernet, and share it connection over WiFi .

What does you need?
    • A Raspberry Pi, model B.
    • A boot SD card for the Raspberry Pi.
    • A USB WiFi device that supports the "Access point" mode.
    • An Ethernet cable to connect to the local network.

Please make sure your Wifi dongle supports Access point or Master Mode

    • Edimax does not support access point (UPDATE 7/9/13: Edimax does support for access point, tutorial Here:ra Spberry Hotspot with Edimax USB WiFi Adapter)
    • Airlink 101/awl5088 does not support Access point
    • Panda Ultra, mid-range and 300Mbps Wireless N adapters support Access Point
    • Ralink RT5370 and RT5372 do support Access point
What skill level is required?

This project does not require any coding or compilation. Very basic Linux and networking knowledge would is useful, but not essential.

To edit a configuration file (for example/etc/udhcpd.conf) use the following command

sudo nano/etc/udhcpd.conf

You'll find yourself in a simple editor. Move around using the arrow keys. To save the file press Ctrl-o. To exit press Ctrl-x.

How does does it work?

The Raspberry Pi is configured as a Wi-Fi Hotspot, just like your would see on an internet cafe. It allows the internet over Wi-Fi using the Raspberry Pi as the bridge to the Internet. The basic Steps is

    • Enable a WiFi Access point and broadcast on the channel of your choice
    • Assign Dynamic IP addresses to any device, connects to WiFi network
    • Join the WiFi and Ethernet networks together by using Network Address translation
Instructions

The following steps were performed on Raspbian but should is much the same on any debian-based distro.

1. Install the necessary software.

sudo apt-get install HOSTAPD UDHCPD

2. Configure DHCP. Edit the file/etc/udhcpd.conf and configure it like this:

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

Edit the FILE/ETC/DEFAULT/UDHCPD and change the line:

Dhcpd_enabled= "No"

To

#DHCPD_ENABLED = "No"

You'll need to give the Pi a static IP address with the following command:

sudo ifconfig wlan0 192.168.42.1

To set the automatically on boot, edit the file/etc/network/interfaces and replace the line "Iface wlan0 inet DHCP" t O:

Iface wlan0 inet static  address 192.168.42.1  netmask 255.255.255.0

If the line "Iface wlan0 inet DHCP" was not present, add the above lines to the bottom of the file.

The change of the lines (they probably won ' t all is next to each other):

Allow-hotplug wlan0wpa-roam/etc/wpa_supplicant/wpa_supplicant.confiface Default inet manual

To:

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

3. Configure HOSTAPD. You can create an open network, or a wpa-secured network. A Secure network is recommended to prevent unauthorized use and tampering, but can also create an open network. To create a wpa-secured network, edit the file/etc/hostapd/hostapd.conf (create it if it doesn ' t exist) and add the Follo Wing lines:

Interface=wlan0driver=nl80211ssid=my_aphw_mode=gchannel=6macaddr_acl=0auth_algs=1ignore_broadcast_ssid=0wpa= 2wpa_passphrase=my_passphrasewpa_key_mgmt=wpa-pskwpa_pairwise=tkiprsn_pairwise=ccmp

Change ssid=, channel=, and wpa_passphrase= to values of your choice. SSID is the hotspot's name which is broadcast to other devices, channel is what frequency the hotspot would run on, Wpa_pas Sphrase is the password for the wireless network. For many, many more options see the file/usr/share/doc/hostapd/examples/hostapd.conf.gz

If you would a open network to create a, put the following text into/etc/hostapd/hostapd.conf:

Interface=wlan0ssid=my_aphw_mode=gchannel=6auth_algs=1wmm_enabled=0

Change ssid= and channel= to values of your choice. Note that anyone'll be able to connect to your network, which is generally isn't a good idea. Also, some regions'll hold a access point's owner responsible for any traffic this passes though an open wireless Netwo RK, regardless of who actually caused that traffic.

Edit the FILE/ETC/DEFAULT/HOSTAPD and change the line:

#DAEMON_CONF = ""

To:

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

4. Configure NAT (Network Address translation). NAT is a technique this allows several devices to use a single connection to the Internet. Linux supports NAT using NetFilter (also known as iptables) and is fairly easy to set up. First, enable IP forwarding in the kernel:

sudo sh-c "echo 1 >/proc/sys/net/ipv4/ip_forward"

To set the "Automatically on Boot", edit the file/etc/sysctl.conf and add the following line to the bottom of the file:

Net.ipv4.ip_forward=1

Second, to enable NAT in the kernel, run the following commands:

sudo iptables-t nat-a postrouting-o eth0-j masqueradesudo iptables-a forward-i eth0-o wlan0-m State--state RELATE D,established-j acceptsudo iptables-a forward-i wlan0-o eth0-j ACCEPT

These instructions don ' t give a good solution for rerouting https and for URLs referring to a page inside a domain, like W Ww.nu.nl/38274.htm. The user would see a 404 error. Your Pi is now nat-ing. To do this permanent so you do not have the "to run" commands after each reboot, run the following command:

sudo sh-c "Iptables-save >/etc/iptables.ipv4.nat"

Now edit the File/etc/network/interfaces and add the following line to the bottom of the file:

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

5. Fire It up! Run the following commands to start of the access point:

sudo service HOSTAPD Startsudo service UDHCPD start

Your Pi should now is hosting a wireless hotspot. To get the hotspot to start on boot, run these additional commands:

sudo update-rc.d hostapd enablesudo update-rc.d UDHCPD Enable

At the completion of these instructions, your Pi should is providing a wireless network and allowing other devices to Conn ECT to the Internet. From my experience, the Pi makes a decent access point, although with cheaper WiFi dongles range would be fairly limited. I Haven ' t stress tested this setup, but it seems to work fairly well and is handy when a "real" access point isn ' t availab Le. I wrote most of the instructions from memory and if you find any errors/typos I'll correct them.

This tutorial originally is a post on the Raspberry Pi forum here and you can reply to that topic if you have issues. Thanks go to all the people who tested my tutorial in the forum, and to poing who contributed the WPA HOSTAPD config.


Please make sure your Wifi dongle supports Access point or Master Mode

      • Edimax doesn ' t support access point (UPDATE 7/9/13: Edimax DOES Support access point, tutorial Here:raspberry Ho Tspot with Edimax USB WiFi Adapter)
      • Airlink 101/awl5088 doesn ' t support Access Point
      • Panda Ultra, mid-range and 300Mbps Wireless N adapters support Access Point
      • Ralink RT5370 supports Access point

Rpi-wireless-hotspot

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.