Apt-get install hostapd
Apt-get install isc-dhcp-server
Accesspoint
Note1: hostapd won’t work with 2 wlan interfaces from which 1 is connected to Internet. Thus use wired internet via Ethernet. This can be also a phone connected to your USB which acts as hotspot.
Note2: hostapd won’t work while wpa_supplicant is active.
example hostapd.conf (/etc/hostapd/hostapd.conf)
interface=wlan0
ssid=somename
hw_mode=g
channel=10
ieee80211d=1
country_code=FR
ieee80211n=1
wmm_enabled=1
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=somepassword
Run command
hostapd /etc/hostapd/hostapd.conf
if it won’t start: killall wpa_supplicant
DHCP server
example of dhcpd.conf (etc/dhcp/dhcpd.conf)
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks…
option domain-name “example.org”;
option domain-name-servers 8.8.8.8;
default-lease-time 600;
max-lease-time 7200;
# This is a very basic subnet declaration.
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.10 192.168.0.20;
option routers 192.168.0.1;
}
To run dhcp server on specific interface, edit /etc/default/isc-dhcp-server;
INTERFACESv4=”wlan0″
because I use 192.168.0.1 as a router, configure wlan0 with this address with command:
ifconfig wlan0 192.168.0.1/24
To start DHCP run command:
/etc/init.d/isc-dhcp-server restart
Route and NAT traffic
to route traffic between network interfaces
echo 1 > /proc/sys/net/ipv4/ip_forward
To translate traffic from wlan0 to eth0
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth0 -o wlan0 -m state –state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT