Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Raspberry Pi3 AccessPoint Setup
- 07.18.2018
- ## environment
- - HW : raspberry pi 3
- - OS : Raspbian GNU/Linux 8
- ## Configuration
- ### Set static ip to wlan0
- ```
- $ sudo vim /etc/network/interfaces
- +allow-hotplug wlan0
- +iface wlan0 inet static
- +address 192.168.42.1
- +netmask 255.255.255.0
- -allow-hotplug wlan1
- - iface wlan1 inet manual
- - wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
- ```
- ```
- $ sudo reboot
- ```
- ```
- $ ifconfig wlan0
- wlan0 Link encap:Ethernet HWaddr b8:27:eb:c1:92:e3
- inet addr:192.168.42.1 Bcast:192.168.42.255 Mask:255.255.255.0
- inet6 addr: fe80::9799:6128:90b:ee3e/64 Scope:Link
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- RX packets:1613 errors:0 dropped:0 overruns:0 frame:0
- TX packets:339 errors:0 dropped:0 overruns:0 carrier:0
- collisions:0 txqueuelen:1000
- RX bytes:146137 (142.7 KiB) TX bytes:54315 (53.0 KiB)
- ```
- ### install dhcp server
- ```
- $ sudo apt-get update
- $ sudo apt-get install isc-dhcp-server
- ```
- ```
- $ sudo vim /etc/dhcp/dhcpd.conf
- - option domain-name "example.org";
- - option domain-name-servers ns1.example.org, ns2.example.org;
- + #option domain-name "example.org";
- + #option domain-name-servers ns1.example.org, ns2.example.org;
- # If this DHCP server is the official DHCP server for the local
- # network, the authoritative directive should be uncommented.
- - # authoritative;
- + authoritative;
- ...
- (at bottom of the file)
- + subnet 192.168.42.0 netmask 255.255.255.0 {
- + range 192.168.42.10 192.168.42.50;
- + option broadcast-address 192.168.42.255;
- + option routers 192.168.42.1;
- + default-lease-time 600;
- + max-lease-time 7200;
- + option domain-name "local";
- + option domain-name-servers 8.8.8.8, 8.8.4.4;
- + }
- ```
- ```
- $ sudo vim /etc/default/isc-dhcp-server
- - INTERFACES=""
- + # INTERFACES=""
- + INTERFACES="wlan0"
- ```
- ```
- $ sudo service isc-dhcp-server restart
- ```
- ### install access point daemon
- ```
- $ sudo apt-get install hostapd
- ```
- ```
- $ sudo vim /etc/hostapd/hostapd.conf
- + interface=wlan0
- + driver=nl80211
- + ssid=Pi3-AccessPoint
- + hw_mode=g
- + channel=6
- + macaddr_acl=0
- + auth_algs=1
- + ignore_broadcast_ssid=0
- + wpa=2
- + wpa_passphrase=******** (network password)
- + wpa_key_mgmt=WPA-PSK
- + wpa_pairwise=TKIP
- + rsn_pairwise=CCMP
- ```
- ```
- $ sudo vim /etc/default/hostapd
- + DAEMON_CONF="/etc/hostapd/hostapd.conf"
- + DAEMON_OPTS="-dd -t -f /home/pi/hostapd.log" ## for logging
- ```
- ### Configure IP routing between the wireless and Ethernet
- ```
- $ sudo vim /etc/sysctl.conf
- # Uncomment the next line to enable packet forwarding for IPv4
- - #net.ipv4.ip_forward=1
- + net.ipv4.ip_forward=1
- ```
- ```
- $ sudo echo 1 > /proc/sys/net/ipv4/ip_forward
- $ cat /proc/sys/net/ipv4/ip_forward
- 1
- ```
- ```
- $ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
- $ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
- $ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
- ```
- ```
- $ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
- ```
- ```
- $ sudo vim /etc/network/interfaces
- (at bottom of the file)
- pre-up iptables-restore < /etc/iptables.ipv4.nat
- ```
- ### verify operation
- ```
- $ sudo reboot
- ```
- ```
- $ sudo service hostapd stop
- $ sudo service hostapd start
- ```
- ```
- $ tail -f /home/pi/hostapd.log
- ```
Add Comment
Please, Sign In to add comment