Raspberry Pi as a Hotspot: Difference between revisions
Created page with "= configure wlan = Assign an IP address to NIC <pre> vi /etc/network/interfaces </pre> add <pre> auto wlan0 </pre> Remark the following lines so the wlan never acts as a cli..." |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 26: | Line 26: | ||
= dhcp = | = dhcp = | ||
Setup DHCP Scope | Setup DHCP Scope. More information can be found at [[DHCP_for_Linux]] | ||
<pre> | <pre> | ||
apt-get install isc-dhcp-server | apt-get install isc-dhcp-server | ||
</pre> | |||
<pre> | |||
vi /etc/dhcp/dhcpd.conf | |||
</pre> | </pre> | ||
Line 42: | Line 46: | ||
range 10.11.12.101 10.11.12.120; | range 10.11.12.101 10.11.12.120; | ||
option broadcast-address 10.11.12.255; | 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; | |||
} | } | ||
</pre> | </pre> | ||
Line 62: | Line 69: | ||
INTERFACES="wlan0" | INTERFACES="wlan0" | ||
</pre> | </pre> | ||
= hostapd = | = hostapd = | ||
Line 93: | Line 99: | ||
= NAT = | = 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 | 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 devices in the car so NAT is not required. | ||
== forwarding == | |||
<pre> | |||
vi /etc/sysctl.conf | |||
</pre> | |||
change | |||
<pre> | |||
#net.ipv4.ip_forward=1 | |||
</pre> | |||
to be | |||
<pre> | |||
net.ipv4.ip_forward=1 | |||
</pre> | |||
== iptables == | |||
<pre> | |||
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 | |||
</pre> | |||
Refer to [[Iptables#Automatic_Load_on_Restart | iptables]] for automatic load on boot. | |||
= reboot = | |||
Lastly reboot and all hopefully will be good. | |||
[[Category : Raspberry Pi]] [[Category : Linux]] | [[Category : Raspberry Pi]] [[Category : Linux]] |
Latest revision as of 11:28, 6 January 2015
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 devices in the car so NAT is not required.
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.
reboot
Lastly reboot and all hopefully will be good.