Navigation

Linux WIFI hotspot

eth1 - internet
wlan1 - internal network

 

Install programs:

 apt-get install dhcp3-server hostapd iptables

 

Set wlan1 IP

ip link set dev wlan1 up
ip addr add 10.10.0.1/24 brd + dev wlan1

 

/etc/hostapd/hostapd.conf

interface=wlan1
bridge=br0
driver=nl80211
ssid=APname
hw_mode=b
channel=1
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_ptk_rekey=600

 

/etc/default/dhcp3-server

INTERFACES="wlan1"

 

/etc/dhcp3/dhcpd.conf

subnet 10.10.0.0 netmask 255.255.255.0 {
   authoritative;
   range 10.10.0.100 10.10.0.200;
   option domain-name-servers 8.8.8.8;
   option routers 10.10.0.1;
   option subnet-mask 255.255.255.0;
   option broadcast-address 10.10.0.255;
   default-lease-time 600;
   max-lease-time 7200;
}

host fix0 # myPC
{
        hardware ethernet 00:11:22:33:44:20;
        fixed-address 10.10.0.50;
}
host fix1 # myMobile
{
        hardware ethernet 00:11:22:33:44:30;
        fixed-address 10.10.0.60;
}

 

Re/start DHCP

 /etc/init.d/dhcp3-server restart

 

Set ip forwarding

echo "1" > /proc/sys/net/ipv4/ip_forward
# or use
sysctl -w net.ipv4.ip_forward=1

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

 

 

Set ip forwarding (permanently)
/etc/sysctl.conf

net.ipv4.ip_forward = 1

 

Run AP (test)

hostapd -dd /etc/hostapd/hostapd.conf
 
Run AP (permanently)
/etc/default/hostapd
RUN_DAEMON="yes"
DAEMON_CONF="/etc/hostapd/hostapd.conf"
DAEMON_OPTS="-dd"

 

Status:

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.10.0.0       *               255.255.255.0   U     0      0        0 wlan1
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
default         192.168.1.1     0.0.0.0         UG    100    0        0 eth1