#!/bin/sh # Local-only hotspot using the internal SoftAP interface (wlan1) # SSID: vegeta black # Password: supermarioinreallife IFACE="wlan1" SSID="vegeta black" PSK="supermarioinreallife" CHANNEL="6" AP_IP="192.168.43.1" NET="192.168.43.0/24" DHCP_RANGE="192.168.43.10,192.168.43.50,12h" [ "$(id -u)" -ne 0 ] && { echo "Need root"; exit 1; } echo "[*] Stopping Android Wi-Fi services (critical step)..." # These commands release the radio so hostapd can take over svc wifi disable 2>/dev/null stop wpa_supplicant 2>/dev/null killall wpa_supplicant hostapd dnsmasq 2>/dev/null sleep 2 echo "[*] Preparing $IFACE..." ip link set "$IFACE" down 2>/dev/null ip addr flush dev "$IFACE" 2>/dev/null # Make sure it is in AP mode iw dev "$IFACE" set type __ap 2>/dev/null || iw dev "$IFACE" set type ap 2>/dev/null ip link set "$IFACE" up sleep 1 # Disable reverse path filter echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter echo 0 > /proc/sys/net/ipv4/conf/"$IFACE"/rp_filter 2>/dev/null # hostapd config cat > /tmp/hostapd-$IFACE.conf </dev/null # Firewall iptables -I INPUT -i $IFACE -j ACCEPT iptables -I OUTPUT -o $IFACE -j ACCEPT iptables -I FORWARD -i $IFACE -j ACCEPT iptables -I FORWARD -o $IFACE -j ACCEPT # DHCP echo "[*] Starting dnsmasq..." dnsmasq \ --interface=$IFACE \ --bind-interfaces \ --dhcp-range=$DHCP_RANGE \ --dhcp-option=3,$AP_IP \ --dhcp-option=6,$AP_IP \ --port=0 \ --no-resolv \ --pid-file=/tmp/dnsmasq-$IFACE.pid & sleep 2 echo echo "=== Status ===" iw dev $IFACE info echo ip -4 addr show $IFACE echo echo "SSID : $SSID" echo "Password : $PSK" echo "Gateway : $AP_IP" echo echo "Connect your PC and try: ping 192.168.43.1"