Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # INSTALL&SETUP PUBLIC WiFi ACCESS POINT
- # TESTED ON UBUNTU 18.04 SERVER
- sudo -s
- #-------------------------------------------------------
- # Unblock WiFi
- apt install rfkill
- systemctl stop NetworkManager
- systemctl disable NetworkManager
- rfkill unblock wifi
- #-------------------------------------------------------
- # Setup WiFi Mode
- apt install net-tools wireless-tools
- AP=$(iwconfig | grep IEEE | cut -f 1 -d " ")
- ifconfig $AP down
- iwconfig $AP mode ad-hoc
- ifconfig $AP up
- #-------------------------------------------------------
- # Install and Setup DHCP server
- apt install isc-dhcp-server
- cat > /etc/default/isc-dhcp-server.conf << EOF
- INTERFACESv4="$AP"
- EOF
- cat > /etc/dhcp/dhcpd.conf << EOF
- subnet 10.0.0.0 netmask 255.255.255.224 {
- range 10.0.0.2 10.0.0.10;
- }
- EOF
- #-------------------------------------------------------
- # Install and Setup Hoastapd (public WiFi-AP)
- apt install hostapd
- cat > /etc/hostapd.conf << EOF
- interface=$AP
- driver=nl80211
- ssid=UbuntuServer1804-Ap
- hw_mode=g
- channel=6
- wpa=2
- wpa_passphrase=parolone
- EOF
- cat > /etc/default/hostapd << EOF
- DAEMON_CONF="/etc/hostapd.conf"
- RUN_DAEMON="yes"
- EOF
- #-------------------------------------------------------
- # Start DHCP and WiFi-AP (set manual-only startup)
- ifconfig $AP 10.0.0.1
- systemctl unmask isc-dhcp-server
- systemctl disable isc-dhcp-server
- systemctl restart isc-dhcp-server
- systemctl unmask hostapd
- systemctl disable hostapd
- systemctl restart hostapd
- #-------------------------------------------------------
- # Check DHCP
- netstat -antup
- dhcp-lease-list --lease /var/db/dhcpd/dhcpd.leases
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement