Raspberry Pi as a Hotspot
configure wlan
Assign an IP address to NIC
vi /etc/network/interfaces
add
auto wlan0
Remark the following lines so the wlan never acts as a client
#allow-hotplug wlan0 #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf #iface default inet manual
Assin an IP address to wlan0
iface wlan0 inet static address 10.11.12.1 netmask 255.255.255.0 wireless-mode Master
dhcp
Setup DHCP Scope. More information can be found at DHCP_for_Linux
apt-get install isc-dhcp-server
vi /etc/dhcp/dhcpd.conf
The following is based on your requirements.
# option definitions common to all supported networks... #option domain-name "example.org"; #option domain-name-servers ns1.example.org, ns2.example.org;
subnet 10.11.12.0 netmask 255.255.255.0 { range 10.11.12.101 10.11.12.120; option broadcast-address 10.11.12.255; option routers 10.11.12.13; option domain-name-servers 8.8.8.8, 8.8.4.4; }
vi /etc/dhcp/dhcpd.conf
Bind DHCP to wlan interface
vi /etc/default/isc-dhcp-server
Change
INTERFACES=""
to
INTERFACES="wlan0"
hostapd
As I have the RTL8188CUS wireless chipset I needed to download a specific version of the hostapd application. Other wireless network cards you could try using the distro package
apt-get install hostapd
otherwise
cd /usr/src wget https://github.com/jenssegers/RTL8188-hostapd/archive/master.zip unzip master.zip cd RTL8188-hostapd-master/hostapd/ make make install
vi /etc/hostapd/hostapd.conf
Configure the following paramaters as required
ssid= channel= wpa_passphrase=
NAT
In my config I have not configured port forwarding and NAT. For my application here I am using the Raspberry Pi with SMB shares so the kids can access TV shows and movies from their android tables in the car so NAT is not required. This also why I have not configure a gateway or name servers in the DHCP server.
forwarding
vi /etc/sysctl.conf
change
#net.ipv4.ip_forward=1
to be
net.ipv4.ip_forward=1
iptables
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
Refer to iptables for automatic load on boot.