Monday, January 9, 2012

Create A WiFi Router

Package needed:

hostapd
dhcp server
ip tables

Get hostapd:
sudo apt-get install hostapd

Edit or create /etc/hostapd/hostapd.conf
ctrl_interface=/var/run/hostapd
#ctrl_interface_group=wheel

# Some usable default settings...
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0

# Uncomment these for base WPA & WPA2 support with a pre-shared key
#wpa=3
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
#rsn_pairwise=CCMP

# DO NOT FORGET TO SET A WPA PASSPHRASE!!
#wpa_passphrase=YourPassPhrase

# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211

# Customize these for your local configuration...
interface=wlan0
hw_mode=g
channel=1
ssid=LinuxReaders

macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=linuxreaderscom
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

To start hostapd:
sudo hostapd -d /etc/hostapd/hostapd.conf

Get Dhcp server:
sudo apt-get install isc-dhcp-server

Edit or create dhcpd.conf
sudo nano /etc/dhcp/dhcpd.conf
option subnet-mask 255.255.255.0;
default-lease-time 360000;
max-lease-time 720000;

option domain-name-servers 8.8.8.8;
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.10 192.168.1.254;
  option broadcast-address 192.168.1.255;
  option routers 192.168.1.1;
}


Edit or create /etc/default/isc-dhcp-server and add wlan0 in INTERFACES
sudo nano /etc/default/isc-dhcp-server

INTERFACES="wlan0"

Assign IP Address to wlan0
sudo ifconfig wlan0 192.168.1.1 netmask 255.255.255.0

Edit /etc/rc.local to get wifi working on every reboot

echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
ifconfig wlan0 inet 192.168.1.1 netmask 255.255.255.0
hostapd -d /etc/hostapd/hostapd.conf &
/etc/init.d/isc-dhcp-server restart

1 comment:

  1. Hi,
    I've been trying to figure out how many connetions the PandaBoard ES can handle at one time when used as a router? I'm trying to turn the PandaBoard ES into a wireless mesh router but am unsure if it can handle the multiple connections.

    ReplyDelete