RaspberryPi 3 as wireless client and wireless AP

Configuring 1 AP + Many wireless connections with One wireless network card.

sudo bash for a root prompt
apt-get install hostapd dnsmasq

Uncomment and edit these lines in /etc/dnsmasq.conf

interface=lo,uap0



no-dhcp-interface=lo,wlan0

dhcp-range=192.168.2.100,192.168.2.200,12h


Edit: /etc/hostapd/hostapd.conf

Add: Change ssid and wpa_passphrase also. (this one is plaintext).

interface=uap0
ssid=pipi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=0123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Edit and add to: /etc/network/interfaces

auto uap0
iface uap0 inet static
address 192.168.2.1
netmask 255.255.255.0

Edit a new file:
pico /usr/local/bin/hostapdstart


add:

iw dev wlan0 interface add uap0 type __ap
service dnsmasq restart
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0/24 -j MASQUERADE
ifup uap0
hostapd /etc/hostapd/hostapd.conf

Change permissions on /usr/local/bin/hostapdstart

chmod 667 /usr/local/bin/hostapdstart

Edit and add line to: /etc/rc.local

hostapdstart >1&

OR just type hostapdstart if you want to see details or if you do not want it to start automatically.

Ignore next step if wlan0 is up and working.
Please configure this prior.. :

Add to /etc/network/interfaces
remove all other wlan0 anything references. then add:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

Replace the psk with yours generated by typing: wpa_passphrase ssidofAP yourWPApass


Your complete /etc/network/interfaces should look like this but with different wpa-psk and wpa-ssid:

auto wlan0
iface wlan0 inet dhcp
wpa-ssid ssidofAP
wpa-psk a03133ea3333471b0d33dbd1b2b19233294649968537c35904eb3389a7df65ba

auto uap0
iface uap0 inet static
address 192.168.2.1
netmask 255.255.255.0

I can confirm that the steps listed above work on a fresh install of raspbian

No comments:

Post a Comment

Note: only a member of this blog may post a comment.