#!/bin/sh GATEWAY="gprs0" INTERFACE="wlan0" IP="192.168.201.1" KEY="1234567890123" ESSID="test" IGNORE_INTERFACE="lo usb0" if [[ -f /tmp/dnsmasq.${INTERFACE}.pid ]]; then echo "dnsmasq pid found, killing it" kill $(cat /tmp/dnsmasq.${INTERFACE}.pid) fi ifconfig ${INTERFACE} down iwconfig ${INTERFACE} mode ad-hoc iwconfig ${INTERFACE} channel auto ifconfig ${INTERFACE} up ifconfig ${INTERFACE} ${IP} iwconfig ${INTERFACE} key s:${KEY} iwconfig ${INTERFACE} essid ${ESSID} dnsmasq -a ${IP} -d -i ${INTERFACE} -z -C /etc/dnsmasq.${INTERFACE}.conf $(for i in ${IGNORE_INTERFACE}; d iptables -t nat -A POSTROUTING -o ${GATEWAY} -j MASQUERADE PID=${!} echo ${PID} > /tmp/dnsmasq.${INTERFACE}.pid