#!/bin/bash
echo "Creation de l'interface wifi en mode ap"
wlanconfig ath0 destroy
wlanconfig ath0 create wlandev wifi0 wlanmode ap
echo "on passe up l'interface on set un essid"
ifconfig ath0 up
iwconfig ath0 essid lestat
ifconfig ath0 172.16.69.1 broadcast 172.16.69.255 netmask 255.255.255.0
echo " conf du serveur dhcpd"
cat > /etc/dhcp/dhcpd.conf <<'EOF'
# dhcp.conf
# Sample DHCP Server Configuration File
# option definitions common to all supported networks...
option domain-name "lucifer.bragon.info";
option domain-name-servers 4.2.2.3;
ddns-update-style none;
authoritative;
default-lease-time 86400;
max-lease-time 86400;
subnet 172.16.69.0 netmask 255.255.255.0 {
range 172.16.69.10 172.16.69.199;
option routers 172.16.69.1;
}
EOF

echo "on start le dhcpd"
/etc/init.d/dhcpd start
echo "regle de nat et firwall"
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "ca devrai rouler et nater si eth0 est sur le net"