Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # INSTALL&SETUP PUBLIC WiFi ACCESS POINT
  4. # TESTED ON UBUNTU 18.04 SERVER
  5.  
  6. sudo -s
  7.  
  8. #-------------------------------------------------------
  9. # Unblock WiFi
  10.  
  11. apt install rfkill
  12.  
  13. systemctl stop NetworkManager
  14. systemctl disable NetworkManager
  15.  
  16. rfkill unblock wifi
  17.  
  18. #-------------------------------------------------------
  19. # Setup WiFi Mode
  20.  
  21. apt install net-tools wireless-tools
  22.  
  23. AP=$(iwconfig | grep IEEE | cut -f 1 -d " ")
  24.  
  25. ifconfig $AP down
  26. iwconfig $AP mode ad-hoc
  27. ifconfig $AP up
  28.  
  29. #-------------------------------------------------------
  30. # Install and Setup DHCP server
  31.  
  32. apt install isc-dhcp-server
  33.  
  34. cat > /etc/default/isc-dhcp-server.conf << EOF
  35. INTERFACESv4="$AP"
  36. EOF
  37.  
  38. cat > /etc/dhcp/dhcpd.conf << EOF
  39. subnet 10.0.0.0 netmask 255.255.255.224 {
  40. range 10.0.0.2 10.0.0.10;
  41. }
  42. EOF
  43.  
  44. #-------------------------------------------------------
  45. # Install and Setup Hoastapd (public WiFi-AP)
  46.  
  47. apt install hostapd
  48.  
  49. cat > /etc/hostapd.conf << EOF
  50. interface=$AP
  51. driver=nl80211
  52. ssid=UbuntuServer1804-Ap
  53. hw_mode=g
  54. channel=6
  55. wpa=2
  56. wpa_passphrase=parolone
  57. EOF
  58.  
  59. cat > /etc/default/hostapd << EOF
  60. DAEMON_CONF="/etc/hostapd.conf"
  61. RUN_DAEMON="yes"
  62. EOF
  63.  
  64. #-------------------------------------------------------
  65. # Start DHCP and WiFi-AP (set manual-only startup)
  66.  
  67. ifconfig $AP 10.0.0.1
  68.  
  69. systemctl unmask isc-dhcp-server
  70. systemctl disable isc-dhcp-server
  71. systemctl restart isc-dhcp-server
  72.  
  73. systemctl unmask hostapd
  74. systemctl disable hostapd
  75. systemctl restart hostapd
  76.  
  77. #-------------------------------------------------------
  78. # Check DHCP
  79.  
  80. netstat -antup
  81. dhcp-lease-list --lease /var/db/dhcpd/dhcpd.leases
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement