• RSSRSS
  • TwitterTwitter
  • FacebookFacebook
  • About
  • Privacy Policy
  • Disclaimer
  • Contact Us

Raspberry Pi Blog

Get Guides,Tips,Tricks And Information Related To Raspberry Pi

Powered by Blogger.
  • Home
  • GPIO
  • I2C
  • SSH
  • LCD
  • Hardware
    • I2C
    • ADC
    • PWM
    • LED
    • LCD
  • Software
    • Python
    • C
    • Programming
    • SSH

convert raspberry pi into a wireless access point
In this post I will demonstrate how to transform the Raspberry Pi into a Wireless Access Point. The majority of this post accompanies what is portrayed here yet I have included a couple more steps.


The process may look a little bit lengthy but it can be finished under 10 minutes. Each time you need to alter or make new record, case in point -[ /etc/udhcpd.conf ] you can utilize "sudo nano /etc/udhcpd.conf".

1. The very first thing to do is to check if the dongle is being detected.Fire up the terminal and type :-
lsusb
If any adapter is detected you should get a message like this:-
Bus 001 Device 005: ID 07d1:3c09 D-Link System DWA-140 RangeBooster N Adapter(rev.B1) [Ralink RT2870]

2.Now you'll need to install the "iw" tool to check which modes are supported by your wireless dongle. Open the terminal and type:-
sudo apt-get install iw
After installation enter iw list. At this point you will see a bunch of specs being printed and some place in the middle you might find something similar to this (the modes beneath are the ones of my dongle that I am utilizing):-

Supported interface modes:
   * IBSS
   * managed
   * AP
   * AP/VLAN
   * WDS
   * monitor
   * mesh point
Depending on the support of AP option you can continue going.

3. Next step is to install "hostapd" and "udhcpd" :-
sudo apt-get install hostapd udhcpd

4. Next we need to configure DHCP so that the Raspberry Pi can distribute IP to the clients. Edit the file /etc/udhcpd.conf with following information:-

start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices.
end 192.168.42.20
interface wlan0 # The device uDHCP listens on.
remaining yes
opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.
opt subnet 255.255.255.0
opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly.
opt lease 864000 # 10 day DHCP lease time in seconds.

5. Next step is to edit the file /etc/default/udchpd and change the line DHCPD_ENABLED="no" to DHCPD_ENABLED="yes"

6. Assign a static IP by entering the following command: sudo ifconfig wlan0 192.168.42.1
To set this up automatically you must edit the file /etc/network/interfaces and replace the line "iface wlan0 inet dhcp" to:
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
If the line "iface wlan0 inet dhcp" does not exist, include the below lines at thebottom part of the file. You will additionally need to update the lines-

allow-hotplug wlan0
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet manual
to
allow-hotplug wlan0
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet manual

7. In order to create network we need to configure hostapd. It can be either an open network or a WPA- secured network for authorized access only.You need to create or edit some files accordingly. The first file that needs to be edited/created is "/etc/hostapd/hostapd.conf". For a WPA-secured network make it look like this:-

interface=wlan0
driver=nl80211
ssid=My_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=My_Passphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

To create an open network enter the following text in the file instead:-

interface=wlan0
ssid=My_AP
hw_mode=g
channel=6
auth_algs=1
wmm_enabled=0

8. Next  step is to change a variable inside the file /etc/default/hostapd so that it points to the file that has been just created/edited. Change this line: DAEMON_CONF="" to DAEMON_CONF="/etc/hostapd/hostapd.conf"

9. The next thing to do is to configure NAT (Network Address Translation) which is a technique that allows several devices to use a single connection to the internet. Edit the file /etc/sysctl.conf and add the following line to the end of the file:
net.ipv4.ip_forward=1
It will enable NAT in the kernel. Now, run the following commands:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
And this concludes the NAT configuration. To make it permanent so you don't have to run the commands after each reboot, run the command
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
and edit the file /etc/network/interfaces and add the following lines to the end of the file:
up iptables-restore < /etc/iptables.ipv4.nat

10. Almost done! Run the following commands to start the Access Point:-
sudo service hostapd start
sudo service udhcpd start
And your Pi should finally be hosting a wireless hotspot!  To get it to start on boot everytime, run these two last commands:
sudo update-rc.d hostapd enable
sudo update-rc.d udhcpd enable
And you're done! If you followed every step correctly everything should be working as expected :-)

led status infi
There are 5 status LED's on the Raspberry Pi board namely [OK, PWR, FDX, LNK, 10M]. FDX, LNK, 10M are connected to the LAN IC- LAN9512. So those 3 LED's will be present only on model B.

According to http://elinux.org/RPi_Hardware

D5(Green) - OK - SDCard Access (via GPIO16)
D6(Red) - PWR - 3.3 V Power
D7(Green) - FDX - Full Duplex (LAN) (Model B)
                                                      D8(Green) - LNK - Link/Activity (LAN) (Model B)
                                                      D9(Yellow) - 10M - 10/100Mbit (LAN) (Model B)

According to the datasheet the pins can also be programmed as GPIO, so these three LEDs could potentially be under software control, but I have not checked if the Linux drivers support this.

Recent Posts

Recent Comments

Blog Archive

  • December (2)
  • November (8)
  • October (3)
  • September (2)
  • August (2)
  • July (3)
  • June (2)
Copyright 2012 SimplexORGMAG. All Rights Reserved.

Designed by WPZoom . Converted to Blogger bySimplexDesign