Guest User

Untitled

a guest
Mar 20th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. sudo apt install dnsmasq hostapd -y
  2.  
  3. sudo echo "denyinterfaces wlan0" | sudo tee -a /etc/dhcpcd.conf
  4.  
  5. sudo tee /etc/network/interfaces.d/wlan0 << EOM
  6. allow-hotplug wlan0
  7. iface wlan0 inet static
  8. address 172.24.1.1
  9. netmask 255.255.255.0
  10. network 172.24.1.0
  11. broadcast 172.24.1.255
  12. EOM
  13.  
  14. sudo service dhcpcd restart
  15.  
  16. sudo ifdown wlan0; sudo ifup wlan0
  17.  
  18. sudo tee /etc/hostapd/hostapd.conf << EOM
  19. # This is the name of the WiFi interface we configured above
  20. interface=wlan0
  21. # Use the nl80211 driver with the brcmfmac driver
  22. driver=nl80211
  23. # This is the name of the network
  24. ssid=Pi3-AP
  25. # Use the 2.4GHz band
  26. hw_mode=g
  27. # Use channel 6
  28. channel=6
  29. # Enable 802.11n
  30. ieee80211n=1
  31. # Enable WMM
  32. wmm_enabled=1
  33. # Enable 40MHz channels with 20ns guard interval
  34. ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
  35. # Accept all MAC addresses
  36. macaddr_acl=0
  37. # Use WPA authentication
  38. auth_algs=1
  39. # Require clients to know the network name
  40. ignore_broadcast_ssid=0
  41. # Use WPA2
  42. wpa=2
  43. # Use a pre-shared key
  44. wpa_key_mgmt=WPA-PSK
  45. # The network passphrase
  46. wpa_passphrase=raspberry
  47. # Use AES, instead of TKIP
  48. rsn_pairwise=CCMP
  49. EOM
  50.  
  51. sudo sed -i "s/^#DAEMON_CONF=\"\"/DAEMON_CONF=\"\/etc\/hostapd\/hostapd.conf\"/" /etc/default/hostapd
  52.  
  53. sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
  54.  
  55. sudo tee /etc/dnsmasq.conf << EOM
  56. interface=wlan0 # Use interface wlan0
  57. listen-address=172.24.1.1 # Explicitly specify the address to listen on
  58. bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere
  59. server=8.8.8.8 # Forward DNS requests to Google DNS
  60. domain-needed # Don't forward short names
  61. bogus-priv # Never forward addresses in the non-routed address spaces.
  62. dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
  63. dhcp-authoritative
  64. EOM
  65.  
  66. sudo sed -i "s/^#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/" /etc/sysctl.conf
  67.  
  68. sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  69. sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  70. sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
  71.  
  72. sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
  73.  
  74. sudo sed -i "s/^exit 0$/sudo iptables-restore < \/etc\/iptables.ipv4.nat\nexit 0/" /etc/rc.local
  75.  
  76. sudo service hostapd start
  77. sudo service dnsmasq start
  78.  
  79. sudo reboot
Add Comment
Please, Sign In to add comment