项目作者: Munkkeli

项目描述 :
Quide to setup a WiFi hotspot with Raspbian Stretch
高级语言:
项目地址: git://github.com/Munkkeli/Raspbian-Stretch-WiFi-Hostspot.git
创建时间: 2018-03-29T07:39:39Z
项目社区:https://github.com/Munkkeli/Raspbian-Stretch-WiFi-Hostspot

开源协议:

下载


Raspberry PI Wi-Fi Hotspot Configuration

Notice

This quide is using the IP 192.168.69.2 for the WiFi hotspot, and the IP 10.94.65.230 for LAN.
Please change these IPs to fit your network.

Updating & Installing

Update & Upgrade the PI

  1. sudo apt-get update
  2. sudo apt-get upgrade

Install DHCPD and HOSTAPD

  1. sudo apt-get install dnsmasq hostapd

Stop the newly added services while thay are configured

  1. sudo systemctl stop dnsmasq
  2. sudo systemctl stop hostapd
  3. `

Configuring DHCPD Client

Configure the static IP addresses for eth0 and wlan0

  1. sudo nano /etc/dhcpcd.conf

Add to the end of the file:

  1. # Configure eth0 for LAN
  2. interface eth0
  3. static ip_address=10.94.65.230/24
  4. static domain_name_servers=192.168.0.1 8.8.8.8
  5. static routers=10.94.65.254
  6. # Disable wlan0 so HOSTAPD can start
  7. denyinterfaces wlan0

Restart the DHCPCD service to apply the changes

  1. sudo service dhcpcd restart

Configuring DHCPD Server

Configure the range of IPs the server will issue out

  1. sudo nano /etc/dnsmasq.conf

Add to the end of the file:

  1. interface=wlan0
  2. dhcp-range=192.168.69.2,192.168.69.22,255.255.255.0,24h

Configuring HOSTAPD

Configuring the WiFi hotspot with HOSTAPD

  1. sudo nano /etc/hostapd/hostapd.conf

Add to the end of the file:

  1. interface=wlan0
  2. driver=nl80211
  3. ssid=Patkis-Air
  4. hw_mode=g
  5. channel=7
  6. ieee80211n=1
  7. wmm_enabled=1
  8. macaddr_acl=0
  9. auth_algs=1
  10. ignore_broadcast_ssid=0
  11. wpa=2
  12. wpa_passphrase=patkis1234
  13. wpa_key_mgmt=WPA-PSK
  14. wpa_pairwise=TKIP
  15. rsn_pairwise=CCMP

Next we need to tell HOSTAPD where the configuration file is

  1. sudo nano /etc/default/hostapd

Find the DAEMON_CONF file and change it to this:

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

Starting Up

Now we can start the services back up

  1. sudo systemctl start hostapd
  2. sudo systemctl start dnsmasq

IP Routing Configuration

We will make out WiFi requests route to the LAN network

  1. sudo nano /etc/sysctl.conf

Uncomment this line:

  1. net.ipv4.ip_forward=1

Add a masquerade for outbound traffic on eth0:

  1. sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Save the iptables rule:

  1. sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Make these rules apply on boot:

  1. sudo nano /etc/rc.local

Add this right before the exit 0 line:

  1. iptables-restore < /etc/iptables.ipv4.nat
  2. ifconfig wlan0 192.168.69.2
  3. service dhcpd restart

Reboot

  1. sudo reboot