Raspberry Pi set to No Line by (AP)

Source: Internet
Author: User

1, install the required package

sudo apt-get install Hostpad UHDCPD

2. Configuring the/etc/network/interfaces File

Configure Wlan0 as static address

The format is as follows:

Iface wlan0 inet Static

Address 192.168.10.1

Netmask 255.255.255.0

Save, exit

3. Configuring the/etc/udhcpd.conf File

Set up automatic assignment of address ranges for DNS gateways, etc.

Specific as follows: (according to individual needs to configure)

Start 192.168.10.2 # This is the range of IPs that the Hostspot would give to client devices.

End 192.168.10.200

Interface Wlan0 # The device udhcp listens on.

Remaining Yes

Opt DNS 8.8.8.8 8.8.4.4 # The DNS servers client devices would use.

opt subnet 255.255.255.0

< EM id= "__mcedel" > opt Router 192.168.10.1 # The Pi ' s IP address on wlan0 which we'll set up shortly.

opt Lease 864000 # ten day DHCP lease time in seconds

4, sudo vim/etc/default/hostpad

Will

#DAEMON_CONF = "" instead

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

5. Edit/etc/hostapd/hostapd.conf

As follows:

    1. # Wlan0 the wireless card as an access point
    2. Interface=wlan0
    3. # using nl80211 Driver
    4. driver=nl80211 (some may be rtl871xdrv, I can't, hint "unknown")
    5. #共享网络的SSID是RaspberryPi
    6. Ssid=raspberrypi (WiFi name)
    7. # NIC works in 802.11G mode
    8. Hw_mode=g
    9. #无线网卡选用11信道
    10. channel=11
    11. # WPA2 Configuration
    12. wpa=2
    13. #wpa密码是raspberry
    14. Wpa_passphrase=raspberry (wifi password)
    15. #认证方式为WPA-psk encryption method is CCMP
    16. Wpa_key_mgmt=wpa-psk
    17. wpa_pairwise=ccmp
    18. rsn_pairwise=ccmp
    19. beacon_int=100
    20. Auth_algs=3
    21. Wmm_enabled=1

6. Edit/ETC/DEFAULT/UDHCPD

Comment it out

#DHCPD_ENABLED =no

7. Configure Route forwarding

The next step is to forward the data from the wireless card wlan0 to the wired card eth0 above the internet via a wired network connection.

Because eth0 is the dynamic IP that is acquired, this is accomplished by Iptables for simple route forwarding.

Input command

    1. sudo iptables-f
    2. sudo iptables-x
    3. sudo iptables-t nat-a postrouting-o eth0-j Masquerade
    4. sudo bash
    5. Iptables-save >/etc/iptables.up.rules
    6. Exit
Copy Code


Input command

    1. sudo nano/etc/network/if-pre-up.d/iptables
Copy Code


Copy and paste the following two lines into the edit window

    1. #!/bin/bash
    2. /sbin/iptables-restore </etc/iptables.up.rules
Copy Code


Save exit
Input command

    1. sudo chmod 755/etc/network/if-pre-up.d/iptables
Copy Code


Turn on kernel forwarding
Input command

    1. sudo nano/etc/sysctl.conf
Copy Code


Find this place

    1. # Uncomment the next line to enable packet forwarding for IPV4
    2. #net. ipv4.ip_forward=1
Copy Code


Get rid of the Net.ipv4.ip_forward front #
Save exit

Input command

    1. sudo sysctl-p
Copy Code

8. Set the service to boot mode

sudo update-rc.d HOSTAPD enable

sudo update-rc.d UDHCPD enable


After that, restart the machine, use mobile phone should be able to see the WiFi set, after connecting, access the following extranet to see if it is available

Raspberry Pi set to No Line by (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.