Difference between revisions of "Raspbian: RPi3 Stand Alone Access Point"

From OnnoWiki
Jump to navigation Jump to search
Line 60: Line 60:
 
  vi /etc/hostapd/hostapd.conf
 
  vi /etc/hostapd/hostapd.conf
  
Add the information below to the configuration file. This configuration assumes we are using channel 7, with a network name of NameOfNetwork, and a password AardvarkBadgerHedgehog. Note that the name and password should not have quotes around them. The passphrase should be between 8 and 64 characters in length.
+
Asumsi
  
To use the 5 GHz band, you can change the operations mode from hw_mode=g to hw_mode=a. Possible values for hw_mode are:
+
Nama WiFi SekolahWiFi
 +
Password  123456789
 +
Pilihan Band hw_mode=g s/d hw_mode=a, pilihan-nya
  
    a = IEEE 802.11a (5 GHz)
+
a = IEEE 802.11a (5 GHz)
    b = IEEE 802.11b (2.4 GHz)
+
b = IEEE 802.11b (2.4 GHz)
    g = IEEE 802.11g (2.4 GHz)
+
g = IEEE 802.11g (2.4 GHz)
    ad = IEEE 802.11ad (60 GHz).
+
ad = IEEE 802.11ad (60 GHz).
 +
 
 +
Contoh isi /etc/hostapd/hostapd.conf
  
 
  interface=wlan0
 
  interface=wlan0
Line 79: Line 83:
 
  ignore_broadcast_ssid=0
 
  ignore_broadcast_ssid=0
 
  wpa=2
 
  wpa=2
  wpa_passphrase=AardvarkBadgerHedgehog
+
  wpa_passphrase=123456789
 
  wpa_key_mgmt=WPA-PSK
 
  wpa_key_mgmt=WPA-PSK
 
  wpa_pairwise=TKIP
 
  wpa_pairwise=TKIP
Line 88: Line 92:
 
  sudo vi /etc/default/hostapd
 
  sudo vi /etc/default/hostapd
  
Find the line with #DAEMON_CONF, and replace it with this:
+
Pastikan
 
 
DAEMON_CONF="/etc/hostapd/hostapd.conf"
 
 
 
Start it up
 
 
 
Now start up the remaining services:
 
 
 
sudo systemctl start hostapd
 
sudo systemctl start dnsmasq
 
 
 
Add routing and masquerade
 
 
 
Edit /etc/sysctl.conf and uncomment this line:
 
 
 
net.ipv4.ip_forward=1
 
 
 
Add a masquerade for outbound traffic on eth0:
 
 
 
sudo iptables -t nat -A  POSTROUTING -o eth0 -j MASQUERADE
 
 
 
Save the iptables rule.
 
 
 
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
 
 
 
Edit /etc/rc.local and add this just above "exit 0" to install these rules on boot.
 
 
 
iptables-restore < /etc/iptables.ipv4.nat
 
 
 
Reboot
 
 
 
Using a wireless device, search for networks. The network SSID you specified in the hostapd configuration should now be present, and it should be accessible with the specified password.
 
 
 
If SSH is enabled on the Raspberry Pi access point, it should be possible to connect to it from another Linux box (or a system with SSH connectivity present) as follows, assuming the pi account is present:
 
 
 
ssh pi@192.168.4.1
 
 
 
By this point, the Raspberry Pi is acting as an access point, and other devices can associate with it. Associated devices can access the Raspberry Pi access point via its IP address for operations such as rsync, scp, or ssh.
 
----------------------------------------------------------------------------------
 
 
 
Using the Raspberry Pi as an access point to share an internet connection (bridge)
 
 
 
One common use of the Raspberry Pi as an access point is to provide wireless connections to a wired Ethernet connection, so that anyone logged into the access point can access the internet, providing of course that the wired Ethernet on the Pi can connect to the internet via some sort of router.
 
 
 
To do this, a 'bridge' needs to put in place between the wireless device and the Ethernet device on the access point Raspberry Pi. This bridge will pass all traffic between the two interfaces. Install the following packages to enable the access point setup and bridging.
 
 
 
sudo apt-get install hostapd bridge-utils
 
 
 
Since the configuration files are not ready yet, turn the new software off as follows:
 
 
 
sudo systemctl stop hostapd
 
 
 
Bridging creates a higher-level construct over the two ports being bridged. It is the bridge that is the network device, so we need to stop the eth0 and wlan0 ports being allocated IP addresses by the DHCP client on the Raspberry Pi.
 
 
 
sudo nano /etc/dhcpcd.conf
 
 
 
Add denyinterfaces wlan0 and denyinterfaces eth0 to the end of the file (but above any other added interface lines) and save the file.
 
 
 
Add a new bridge, which in this case is called br0.
 
 
 
sudo brctl addbr br0
 
 
 
Connect the network ports. In this case, connect eth0 to the bridge br0.
 
 
 
sudo brctl addif br0 eth0
 
 
 
Now the interfaces file needs to be edited to adjust the various devices to work with bridging. sudo nano /etc/network/interfaces make the following edits.
 
 
 
Add the bridging information at the end of the file.
 
 
 
# Bridge setup
 
auto br0
 
iface br0 inet manual
 
bridge_ports eth0 wlan0
 
 
 
The access point setup is almost the same as that shown in the previous section. Follow the instructions above to set up the hostapd.conf file, but add bridge=br0 below the interface=wlan0 line, and remove or comment out the driver line. The passphrase must be between 8 and 64 characters long.
 
 
 
To use the 5 GHz band, you can change the operations mode from 'hw_mode=g' to 'hw_mode=a'. Possible values for hw_mode are:
 
 
 
    a = IEEE 802.11a (5 GHz)
 
    b = IEEE 802.11b (2.4 GHz)
 
    g = IEEE 802.11g (2.4 GHz)
 
    ad = IEEE 802.11ad (60 GHz).
 
 
 
interface=wlan0
 
bridge=br0
 
#driver=nl80211
 
ssid=NameOfNetwork
 
hw_mode=g
 
channel=7
 
wmm_enabled=0
 
macaddr_acl=0
 
auth_algs=1
 
ignore_broadcast_ssid=0
 
wpa=2
 
wpa_passphrase=AardvarkBadgerHedgehog
 
wpa_key_mgmt=WPA-PSK
 
wpa_pairwise=TKIP
 
rsn_pairwise=CCMP
 
 
 
Now reboot the Raspberry Pi.
 
 
 
sudo reboot
 
 
 
There should now be a functioning bridge between the wireless LAN and the Ethernet connection on the Raspberry Pi, and any device associated with the Raspberry Pi access point will act as if it is connected to the access point's wired Ethernet.
 
 
 
The ifconfig command will show the bridge, which will have been allocated an IP address via the wired Ethernet's DHCP server. The wlan0 and eth0 no longer have IP addresses, as they are now controlled by the bridge. It is possible to use a static IP address for the bridge if required, but generally, if the Raspberry Pi access point is connected to a ADSL router, the DHCP address will be fine.
 
View/Edit this page on GitHub
 
Read our usage and contributions policy
 
Creative Commons Licence
 
 
 
    Like Raspberry Pi on Facebook
 
    Follow Raspberry Pi on Twitter
 
    Check out what we’re having for lunch on Instagram
 
    Connect with us on Google Plus or whatever happens over there
 
    Subscribe to the Raspberry Pi YouTube channel
 
 
 
About Us
 
 
 
    About us
 
    Our team
 
    Governance
 
    Our supporters
 
    Jobs
 
    Contact us
 
 
 
Support
 
 
 
    Help
 
    Documentation
 
    Projects
 
    Training
 
    Downloads
 
    Research
 
    FAQ
 
 
 
Sign up to our newsletter
 
 
 
Raspberry Pi Foundation
 
UK Registered Charity 1129409
 
  
Privacy Cookies Trademark rules and brand guidelines
+
DAEMON_CONF="/etc/hostapd/hostapd.conf"
  
 +
==Restart==
  
 +
sudo systemctl start hostapd
 +
sudo systemctl start dnsmasq
  
 +
==Reboot==
  
 +
sudo reboot
  
 +
==Pranala Menarik==
  
 +
* [[Internet Offline]]
  
 
==Referensi==
 
==Referensi==

Revision as of 17:20, 10 October 2018

Sumber: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

Membuat RaspberryPi 3 menjadi stand alone access point WiFi.

Instalasi

Instalasi

sudo su
apt-get update
apt-get upgrade
apt-get install dnsmasq hostapd

Karena belum siap, di stop / off dulu

sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

Reboot untuk meng-update kernel

sudo reboot

IP Statik

Edit

sudo vi /etc/dhcpcd.conf

Tambahkan di akhir file

interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

Restart

sudo service dhcpcd restart

Konfigurasi DHCP Server (dnsmasq)

Lakukan

sudo su
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig  
vi /etc/dnsmasq.conf

Tambahkan

interface=wlan0      # Use the require wireless interface - usually wlan0
  dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
interface=eth0      # Use the require wireless interface - usually wlan0
  dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,24h

Konfigurasi Access Point (hostap)

Edit

sudo su
vi /etc/hostapd/hostapd.conf

Asumsi

Nama WiFi SekolahWiFi
Password  123456789
Pilihan Band hw_mode=g s/d hw_mode=a, pilihan-nya
a = IEEE 802.11a (5 GHz)
b = IEEE 802.11b (2.4 GHz)
g = IEEE 802.11g (2.4 GHz)
ad = IEEE 802.11ad (60 GHz).

Contoh isi /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=SekolahWiFi
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=123456789
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP 

Edit

sudo vi /etc/default/hostapd

Pastikan

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Restart

sudo systemctl start hostapd
sudo systemctl start dnsmasq

Reboot

sudo reboot

Pranala Menarik

Referensi


Pranala Menarik