aptitude install hostapd service hostapd stop
DAEMON_CONF="/etc/hostapd/hostapd.conf"
interface=wlan0 driver=nl80211 ssid=wifi_4_friends hw_mode=g channel=6 wpa=2 wpa_passphrase=12345678 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP auth_algs=1 macaddr_acl=0
aptitude install dnsmasq service dnsmasq stop
interface=wlan0 dhcp-range=192.168.2.2,192.168.2.100,12h
update-rc.d hostapd disable update-rc.d dnsmasq disable
sysctl net.ipv4.ip_forward=1 iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
#!/bin/bash #script to start/stop hostapd, dnsmasq, add/remove iptables rule set -e exec 3>&1 exec 2>&1 >> /tmp/wifi-ap function print_help(){ echo "Start/Stop Software Access Point" echo echo "Usage `basename $0` options..." echo "wifi-ap on to start Software AP" echo "wifi-ap off to stop Software AP" echo echo "log-file - /tmp/wifi-ap" echo } if [ $# = 0 ]; then print_help >&3 exit 0 fi if [ $1 = on ]; then ifconfig wlan0 192.168.2.1 service dnsmasq start sysctl net.ipv4.ip_forward=1 iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE service hostapd start notify-send --expire-time=4000 "Software Access Point" "<b>start</b>" exit 0 fi if [ $1 = off ]; then service dnsmasq stop service hostapd stop ifconfig wlan0 192.168.1.4 sysctl net.ipv4.ip_forward=0 iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE notify-send --expire-time=4000 "Software Access Point" "<b>stop</b>" exit 0 fi
Source: https://habr.com/ru/post/210426/
All Articles