Guest User

Untitled

a guest
Oct 18th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. # Raspberry as a standolone Wi-Fi Access Point
  2.  
  3. A reminder on how to configure a Raspberry Pi 3 (Debian Jessie) as a Wi-Fi Access Point
  4.  
  5. ## Find the Raspberry Pi ethernet ip-address
  6.  
  7. > Instructions for the macOS platform, little trick to find the raspberry pi ip-address while connected through ethernet.
  8.  
  9. Connect the Raspberry Pi with an ethernet cable
  10.  
  11. ```sh
  12. $ ifconfig
  13. ```
  14.  
  15. Then look for the `bridge100` interface, and get the inet ipaddress (for me `192.168.2.1`).
  16. You can use nmap to scan for all ips and guess the raspberry pi one.
  17.  
  18. ```sh
  19. $ brew install nmap
  20. $ nmap -n -sP 192.168.2.1/24
  21. ```
  22.  
  23. ## Install the dependencies
  24.  
  25. ```sh
  26. $ ssh pi@<ip-address>
  27. pi@raspberrypi:~ $ sudo apt-get install hostapd dnsmasq
  28. ```
  29.  
  30. ## /etc/dhcpcd.conf
  31.  
  32. Configure a static ip profile for the `wlan0` interface. In Debian Jessie, it's done in the `/etc/dhcpcd.conf` configuration file.
  33.  
  34. ```sh
  35. pi@raspberrypi:~ $ cat <<EOT >> /etc/dhcpcd.conf
  36.  
  37. # define static profile
  38. interface wlan0
  39. static ip_address=192.168.1.23/24
  40. static routers=192.168.1.1
  41. static domain_name_servers=192.168.1.1 8.8.8.8
  42. EOT
  43. ```
  44.  
  45. ## /etc/dnsmasq.conf
  46.  
  47. Configure the Dnsmasq service on the wlan0 interface
  48.  
  49. ```sh
  50. pi@raspberrypi:~ $ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
  51. pi@raspberrypi:~ $ sudo touch /etc/dnsmasq.conf
  52. pi@raspberrypi:~ $ sudo tee <<EOT /etc/dnsmasq.conf >/dev/null
  53. interface=wlan0
  54. domain-needed
  55. bogus-priv
  56. dhcp-range=192.168.1.24,192.168.1.250,12h
  57. EOT
  58. ```
  59.  
  60. ## /etc/hostapd.conf
  61.  
  62. ```sh
  63. pi@raspberrypi:~ $ sudo tee <<EOT /etc/hostadp/hostadp.conf >/dev/null
  64. # Interface Settings
  65. interface=wlan0
  66. driver=nl80211
  67.  
  68. # Wifi AP Settings
  69. ssid=BlackHat
  70. wpa_passphrase=DontTryMe
  71. hw_mode=g
  72. channel=6
  73. ieee80211n=1
  74.  
  75. # Encryption Settings
  76. auth_algs=1
  77. wpa=2
  78. wpa_key_mgmt=WPA-PSK
  79. wpa_pairwise=TKIP
  80. rsn_pairwise=CCMP
  81.  
  82. # Accept all MAC addresses
  83. macaddr_acl=0
  84.  
  85. # Require clients to know the network name
  86. #ignore_broadcast_ssid=0
  87.  
  88. # Enable WMM (QoS)
  89. wmm_enabled=0
  90.  
  91. EOT
  92. ```
  93.  
  94. ## Forward ipv4 and ipv6
  95.  
  96. ```sh
  97. pi@raspberrypi:~ $ sudo touch /etc/sysctl.d/50-hostapd.conf
  98. pi@raspberrypi:~ $ sudo tee <<EOT /etc/sysctl.d/50-hostapd.conf >/dev/null
  99. net.ipv4.ip_forward=1
  100. net.ipv6.conf.all.forwarding=1
  101. EOT
  102. ```
  103.  
  104. ## Restart the services
  105.  
  106. For an unknown reason (yet), restarting the services is not enough, you should reboot your Raspberry Pi in order to make it work with our new configuration.
  107.  
  108. ```sh
  109. pi@raspberrypi:~ $ sudo reboot
  110. ```
  111.  
  112. Then once it's up and running, you need to check if all services are loaded and running too.
  113.  
  114. ```sh
  115. pi@raspberrypi:~ $ sudo systemctl status dhcpcd.service
  116. pi@raspberrypi:~ $ sudo systemctl status dnsmasq.service
  117. pi@raspberrypi:~ $ sudo systemctl status hostapd.service
  118. ```
Add Comment
Please, Sign In to add comment