2015年1月11日 星期日

[Raspberry Pi][ArchLinux] Set WiFi Access Point in ArchLinux

0. Update archlinux repository database
pacman -Syu

1. Install hostapd dnsmasq
pacman -S hostapd dnsmasq

For need unzip command
pacman -S unzip

2.
Because hostapd not compatible with Realtek RTL8188CUS. So change hostapd to suit for RTL8188CUS.
wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip
unzip hostapd.zip
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo mv hostapd /usr/sbin/hostapd.edimax
chmod 755 /usr/sbin/hostapd.edimax
sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd
sudo chown root.root /usr/sbin/hostapd
sudo chmod 755 /usr/sbin/hostapd


3. Configure the configuration of hostapd
vim /root/hostapd.conf
interface=wlan0
driver=rtl871xdrv
ssid=RaspberryPi
channel=1
wmm_enabled=0
wpa=1
wpa_passphrase=0000011111
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0


4. Setting DHCP server
vim /etc/dnsmasq.conf

Way 1:
interface=wlan0
server=10.0.0.1
dhcp-range=10.0.0.2,10.0.0.20,12h

Way 2:
interface=wlan0
server=192.168.1.1
dhcp-range=192.168.1.2,192.168.1.253,12h


5. Setting the IP of wlan0
Way 1:
ifconfig wlan0 10.0.0.1

Way 2:
ifconfig wlan0 192.168.1.1

6. Start DHCP server
systemctl start dnsmasq


Start WiFi AP
hostapd -dd /root/hostapd.conf &


7. Set forwarding rule into iptables
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
(ppp0 is output network interface)
iptables -A FORWARD -i ppp0 -o wlan0 -j ACCEPT
iptables -A FORWARD -i wlan0 -o ppp0 -j ACCEPT

8. Check DNS settings
vim /etc/resolv.conf

Add following parameter
nameserver 8.8.8.8
nameserver 8.8.4.4

9. Set ppp0 as defalut gw
route add default gw 10.64.64.64

Reference:

1. [Raspberry Pi] WiFi-AP by using Edimax(EW-7811UN)
2. How to set up wireless lan card on laptops as wifi access point in Linux with WPA2-PSK Security
3. Download Arch Linux Raspberry Pi WiFi Access Point Image
4. How to share ppp0 to wlan0 with redsocks
5. How do I set my DNS on Ubuntu 14.04?
6. [SOLVED]How do I forward ppp0 traffic to a wifi usb running as a WAP? 7. Raspberry Pi 的應用 - Wifi 無線基地台

0 意見:

張貼留言