{"id":289,"date":"2014-05-17T11:34:31","date_gmt":"2014-05-17T11:34:31","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=289"},"modified":"2015-09-14T21:35:31","modified_gmt":"2015-09-14T21:35:31","slug":"turn-your-raspberry-pi-into-a-wireless-hotspot","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/turn-your-raspberry-pi-into-a-wireless-hotspot\/","title":{"rendered":"Turn Your Raspberry Pi into a Wireless  Hotspot"},"content":{"rendered":"<p>Goal:<\/p>\n<p>The goal of this guide is to turn a Raspberry Pi into a wireless home\/mobile router.<\/p>\n<p>Equipment:<\/p>\n<ol>\n<li>Raspberry Pi with raspbian<\/li>\n<li>Wireless USB device.\u00a0 The guide uses a Edimax Nano USB Wifi (EW-7811Un) adapter<\/li>\n<li>Ethernet cat5 cable to connect to the Internet<\/li>\n<\/ol>\n<p>Lets get started.<\/p>\n<p>Install the following packages.<\/p>\n<pre>sudo apt-get install hostapd dnsmasq iptables<\/pre>\n<p>Open up &#8220;\/etc\/network\/interfaces&#8221; and add the following lines.\u00a0 If there is a line for wlan0 you can comment it out with a &#8220;#&#8221;.<\/p>\n<pre>iface wlan0 inet static\r\naddress 192.168.42.17\r\nnetmask 255.255.255.0\r\n<\/pre>\n<p><strong>Configure Hostapd<\/strong><\/p>\n<p>Edit the following file &#8220;<em>\/etc\/default\/hostapd&#8221; so it looks like this.<\/em><\/p>\n<pre>DAEMON_CONF=\"\/etc\/hostapd\/hostapd.conf\"<\/pre>\n<p>Now edit the hostapd config file &#8220;\/etc\/hostapd\/hostapd.conf&#8221; and configure the wireless access point.<\/p>\n<pre><code>interface=wlan0\r\ndriver=rtl871xdrv\r\nbridge=br0\r\nssid=MC\r\nchannel=1\r\nwmm_enabled=0\r\nwpa=1\r\nwpa_passphrase=min3cr@ft\r\nwpa_key_mgmt=WPA-PSK\r\nwpa_pairwise=TKIP\r\nrsn_pairwise=CCMP\r\nauth_algs=1\r\nmacaddr_acl=0 <\/code>\r\n<\/pre>\n<p><strong>\u00a0Configure the DHCP Server<\/strong><\/p>\n<p>For the DHCP server we just need to add the following lines to &#8220;\/etc\/dnsmasq.conf&#8221;<\/p>\n<pre>interface=wlan0\r\ndhcp-range=192.168.42.20,192.168.42.152,255.255.255.0,12h\r\ndhcp-option=3,192.168.42.17\r\n<\/pre>\n<p><strong>Configure Iptables<\/strong><\/p>\n<p>Now we need to set it up so the pi can forward traffic from wlan0 to eth0.<\/p>\n<p>Edit &#8220;\/etc\/sysctl.conf&#8221; and uncomment the following line<\/p>\n<pre>net.ipv4.ip_forward=1<\/pre>\n<p>then execute<\/p>\n<pre>sysctl -p<\/pre>\n<p>Next create an iptables &#8220;config&#8221; file.<\/p>\n<pre>sudo touch \/etc\/network\/if-up.d\/router.sh\r\nsudo chmod +x \/etc\/network\/if-up.d\/router.sh\r\nsudo su -c \"echo '\/etc\/network\/if-up.d\/router.sh' &gt;&gt; \/etc\/rc.local\"\r\n<\/pre>\n<p>Add the following line to the file.<\/p>\n<pre>sudo iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE\r\nsudo iptables --append FORWARD --in-interface wlan0 -j ACCEPT\r\n<\/pre>\n<p>If you are using the same wireless adapter that is used in this guide then you will need to execute the following commands to replace the hostapd binary.\u00a0 You can find more info <a href=\"http:\/\/www.daveconroy.com\/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset\/\">here<\/a>.<\/p>\n<pre>wget http:\/\/www.daveconroy.com\/wp3\/wp-content\/uploads\/2013\/07\/hostapd.zip\r\nunzip hostapd.zip\r\nsudo mv \/usr\/sbin\/hostapd \/usr\/sbin\/hostapd.bak\r\nsudo mv hostapd \/usr\/sbin\/hostapd.edimax\r\nsudo ln -sf \/usr\/sbin\/hostapd.edimax \/usr\/sbin\/hostapd\r\nsudo chown root.root \/usr\/sbin\/hostapd\r\nsudo chmod 755 \/usr\/sbin\/hostapd<\/pre>\n<p>That should do it. Plug in the Ethernet cable and reboot\u00a0 your pi and you should be good to go.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Goal: The goal of this guide is to turn a Raspberry Pi into a wireless home\/mobile router. Equipment: Raspberry Pi with raspbian Wireless USB device.\u00a0 The guide uses a Edimax Nano USB Wifi (EW-7811Un) adapter Ethernet cat5 cable to connect &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/turn-your-raspberry-pi-into-a-wireless-hotspot\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[91],"tags":[117,116,105,92,114,115],"class_list":["post-289","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","tag-access-point","tag-ap","tag-pi","tag-raspberry-pi-2","tag-wifi","tag-wireless"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=289"}],"version-history":[{"count":18,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/289\/revisions"}],"predecessor-version":[{"id":1161,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/289\/revisions\/1161"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}