Guest User

Untitled

a guest
Jul 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. # Raspberry Pi3 AccessPoint Setup
  2. 07.18.2018
  3.  
  4. ## environment
  5. - HW : raspberry pi 3
  6. - OS : Raspbian GNU/Linux 8
  7.  
  8.  
  9. ## Configuration
  10. ### Set static ip to wlan0
  11. ```
  12. $ sudo vim /etc/network/interfaces
  13.  
  14. +allow-hotplug wlan0
  15. +iface wlan0 inet static
  16. +address 192.168.42.1
  17. +netmask 255.255.255.0
  18. -allow-hotplug wlan1
  19. - iface wlan1 inet manual
  20. - wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
  21. ```
  22. ```
  23. $ sudo reboot
  24. ```
  25. ```
  26. $ ifconfig wlan0
  27. wlan0 Link encap:Ethernet HWaddr b8:27:eb:c1:92:e3
  28. inet addr:192.168.42.1 Bcast:192.168.42.255 Mask:255.255.255.0
  29. inet6 addr: fe80::9799:6128:90b:ee3e/64 Scope:Link
  30. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  31. RX packets:1613 errors:0 dropped:0 overruns:0 frame:0
  32. TX packets:339 errors:0 dropped:0 overruns:0 carrier:0
  33. collisions:0 txqueuelen:1000
  34. RX bytes:146137 (142.7 KiB) TX bytes:54315 (53.0 KiB)
  35. ```
  36.  
  37. ### install dhcp server
  38. ```
  39. $ sudo apt-get update
  40. $ sudo apt-get install isc-dhcp-server
  41. ```
  42. ```
  43. $ sudo vim /etc/dhcp/dhcpd.conf
  44.  
  45. - option domain-name "example.org";
  46. - option domain-name-servers ns1.example.org, ns2.example.org;
  47. + #option domain-name "example.org";
  48. + #option domain-name-servers ns1.example.org, ns2.example.org;
  49.  
  50. # If this DHCP server is the official DHCP server for the local
  51. # network, the authoritative directive should be uncommented.
  52. - # authoritative;
  53. + authoritative;
  54.  
  55. ...
  56.  
  57. (at bottom of the file)
  58. + subnet 192.168.42.0 netmask 255.255.255.0 {
  59. + range 192.168.42.10 192.168.42.50;
  60. + option broadcast-address 192.168.42.255;
  61. + option routers 192.168.42.1;
  62. + default-lease-time 600;
  63. + max-lease-time 7200;
  64. + option domain-name "local";
  65. + option domain-name-servers 8.8.8.8, 8.8.4.4;
  66. + }
  67. ```
  68. ```
  69. $ sudo vim /etc/default/isc-dhcp-server
  70.  
  71. - INTERFACES=""
  72. + # INTERFACES=""
  73. + INTERFACES="wlan0"
  74. ```
  75. ```
  76. $ sudo service isc-dhcp-server restart
  77. ```
  78.  
  79. ### install access point daemon
  80. ```
  81. $ sudo apt-get install hostapd
  82. ```
  83. ```
  84. $ sudo vim /etc/hostapd/hostapd.conf
  85.  
  86. + interface=wlan0
  87. + driver=nl80211
  88. + ssid=Pi3-AccessPoint
  89. + hw_mode=g
  90. + channel=6
  91.  
  92. + macaddr_acl=0
  93. + auth_algs=1
  94. + ignore_broadcast_ssid=0
  95. + wpa=2
  96. + wpa_passphrase=******** (network password)
  97. + wpa_key_mgmt=WPA-PSK
  98. + wpa_pairwise=TKIP
  99. + rsn_pairwise=CCMP
  100. ```
  101. ```
  102. $ sudo vim /etc/default/hostapd
  103. + DAEMON_CONF="/etc/hostapd/hostapd.conf"
  104. + DAEMON_OPTS="-dd -t -f /home/pi/hostapd.log" ## for logging
  105. ```
  106.  
  107. ### Configure IP routing between the wireless and Ethernet
  108. ```
  109. $ sudo vim /etc/sysctl.conf
  110.  
  111. # Uncomment the next line to enable packet forwarding for IPv4
  112. - #net.ipv4.ip_forward=1
  113. + net.ipv4.ip_forward=1
  114. ```
  115. ```
  116. $ sudo echo 1 > /proc/sys/net/ipv4/ip_forward
  117. $ cat /proc/sys/net/ipv4/ip_forward
  118. 1
  119. ```
  120. ```
  121. $ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  122. $ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  123. $ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
  124. ```
  125. ```
  126. $ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
  127. ```
  128. ```
  129. $ sudo vim /etc/network/interfaces
  130.  
  131. (at bottom of the file)
  132. pre-up iptables-restore < /etc/iptables.ipv4.nat
  133. ```
  134.  
  135.  
  136. ### verify operation
  137. ```
  138. $ sudo reboot
  139. ```
  140. ```
  141. $ sudo service hostapd stop
  142. $ sudo service hostapd start
  143. ```
  144. ```
  145. $ tail -f /home/pi/hostapd.log
  146. ```
Add Comment
Please, Sign In to add comment