Академический Документы
Профессиональный Документы
Культура Документы
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
Raspberry Pi HQ
Your resource for Raspberry Pi Projects
Home
About
GettingStarted
Projects
Resources
RaspberryPiwithEdimaxWifiAdapter
AdapterthatmentionsLinuxinthe
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
1/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
productdescriptionorpackage.Iuse
theEdimaxWireless802.11b/g/nnanoUSBadapterbecauseIhavefoundittobecheap
andveryeasytoworkwith.Iveryrecommendyoudothesameitcouldsaveyoualotof
headaches.
dmesg|more
Youcanusethespacebartoscrolldownapageatatimetowardstheendyouwillsee
somethingsimilartothefollowinglines:
[3.282651]usb11.2:newhighspeedUSBdevicenumber4usingdwc_otg
[3.394810]usb11.2:NewUSBdevicefound,idVendor=7392,idProduct=7811
[3.407489]usb11.2:NewUSBdevicestrings:Mfr=1,Product=2,SerialNumber=3
[3.420530]usb11.2:Product:802.11nWLANAdapter
ThismeansthattheoperatingsystemrecognizedtheUSBWiFiAdapterusingoneofthebuilt
indrivers(youcanreturntotheterminalbypressingq).Allthatisleftistoconfigureyour
WiFiconnection.
2/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
server.ADHCPserverisresponsibleforassigningaddressestocomputersand
devicesconnectiontotheWiFiaccesspoint.
ToinstalltheDHCPsoftwarerunthefollowingcommand:
sudoaptgetinstalliscdhcpserver
NextupistheHostAPDsoftware.BecauseourUSBstickneedsanaccesspointdrivernot
supportedbythenativeHostAPDapplicationwemustinstallacustomversioncompiledwith
thedriverweneed.Thiscanbedonebyrunningthefollowingcommandsoneatatime.
wgethttps://github.com/jenssegers/RTL8188hostapd/archive/v1.1.tar.gz
tarzxvfv1.1.tar.gz
cdRTL8188hostapd1.1/hostapd
sudomake
sudomakeinstall
Thiswilltakealittletimewhilewaitingfortheprogramtocompilesendafriendlythought
toJensSegersoverathttp://jenssegers.beformakingthissoftwareavailable.
Oncedownloadedwearereadytoconfigurethesoftware.
sudonano/etc/dhcp/dhcpd.conf
Findthefollowingsectionandcommentitoutbyplacingahashtagatthebeginningoftheline.
optiondomainname"example.org";
optiondomainnameserversns1.example.org,ns2.example.org;
Nextfindthesectionbelowanduncommentthewordauthoritative(removehastag):
#IfthisDHCPserveristheofficialDHCPserverforthelocal
#network,theauthoritativedirectiveshouldbeuncommented.
#authoritative;
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
3/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
Thefilenowlookslikethis:
NextweneedtodefinethenetworkandnetworkaddressesthattheDHCPserverwillbe
serving.Thisisdonebyaddingthefollowingblockofconfigurationtotheendoffile:
subnet192.168.10.0netmask255.255.255.0{
range192.168.10.10192.168.10.20;
optionbroadcastaddress192.168.10.255;
optionrouters192.168.10.1;
defaultleasetime600;
maxleasetime7200;
optiondomainname"localnetwork";
optiondomainnameservers8.8.8.8,8.8.4.4;
}
ThiswillenabletheDHCPservertohandouttheipaddressesfrom192.168.10.10to
192.168.10.20initsownlocalnetwork.Peoplewhoareskilledinnetworkconfigurationcan
changethesevaluesiftheywishtousesomeothernetworkaddressesand/orotherDNS
servers.ThisconfigurationwillusetheGoogleDNSserversat8.8.8.8and8.8.4.4.
TosavethefilepressCtrl+Othiswillwritethefiletothediskafterwardsyoucanexitnano
bypressingCtrl+X.IfnanoasksifyouwanttoSavemodifiedbuffer?pressYfollowedby
hittingentertoconfirmthefilename.
Nextfiletoeditis/etc/default/iscdhcpserver,youcanopenitinnanousingthiscommand:
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
4/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
sudonano/etc/default/iscdhcpserver
Scrolldowntothelinesayinginterfacesandupdatethelinetosay:
INTERFACES="wlan0"
ThiswillmaketheDHCPserverhandoutnetworkaddressesonthewirelessinterface.Save
thefileandexitnano.
ThelaststepinconfiguringtheDHCPserveristoconfigureastaticipaddressforthewireless
networkadapter.Thisisdoneinthefile/etc/network/interfacesbeforeopeningitmakesure
theWLANinterfaceisdown.Dothiswiththefollowingcommands:
sudoifdownwlan0
sudonano/etc/network/interfaces
Changethefiletolooklikethis:
Thiswillmakethewirelessadaptertaketheaddress192.168.10.1inournewlocalnetwork.
Remembertocommentoutthelast3linesofthefile.
ThisconcludesthesetupoftheDHCPserverhoweverwestillcannotconnecttoournew
networkbecausewehavenotsetuptheaccesspointyet.Thisisdonebyconfiguringthe
hostapdapplication.
Configuring HostAPD
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
5/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
ToconfigureHostAPD,openthefilecalled/etc/hostapd/hostapd.confinyourfavoritetext
editor.Youcanopenitinnanousingthiscommand:
sudonano/etc/hostapd/hostapd.conf
Thestandardconfigurationwillcreateanewwirelessnetworkcalledwifiwiththepassword
YourPassPhrase.Youcanchangetheparameterssid=wifitotheSSIDwifinameyouwant
andtheparameterwpa_passphrase=YourPassPhrasetoyourownpassword.
ThisconcludestheconfigurationofouraccesspointsoftwareHostAPD.Nextupisenabling
NAT.
Enable NAT
ThelaststepbeforewecanstarttheaccesspointissettingupNetworkAddressTranslation
(NAT).Thiswillmakesurethatournetworktrafficwillbeabletoreachtheinternetusingthe
RaspberryPisEthernetcableconnectiontoyourinternetrouter.
Open/etc/sysctl.confwith:
sudonano/etc/sysctl.conf
Scrolldowntothelastlineofthefileandaddtheline:
net.ipv4.ip_forward=1
Nextstartthetranslationrightawaybyrunning:
sudoshc"echo1>/proc/sys/net/ipv4/ip_forward"
Startthewirelessnetworkbyrunning:
sudoifupwlan0
Nextstepissettinguptheactualtranslationbetweentheethernetportcalledeth0andthe
wirelesscardcalledwlan0.
sudoiptablestnatAPOSTROUTINGoeth0jMASQUERADE
sudoiptablesAFORWARDieth0owlan0mstatestateRELATED,ESTABLISHEDjACCEPT
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
6/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
sudoiptablesAFORWARDiwlan0oeth0jACCEPT
WiththeNATconfigureditisnowtimetorunyouraccesspointforthefirsttime.
sudoserviceiscdhcpserverstart
sudoservicehostapdstart
Atthispointyoushouldbeabletofindyourwirelessnetworkonyourlaptopandconnecttoit
andtheinternet!
Finishing up
WhileitisprettycoolyounowhaveyourRaspberryPirunningasawirelessaccesspointitis
notsocoolyouhavetologineverytimeitrebootstostarttheHostAPDandDHCPsoftware
Toavoidthisrunthefollowingcommands:
sudoupdaterc.dhostapdenable
sudoupdaterc.discdhcpserverenable
ToavoidhavingtoconfigureNATeverytimetheRaspberryPirebootsyoucandothe
following.
RunthiscommandtobackuptheNATconfiguration.
sudoshc"iptablessave>/etc/iptables.ipv4.nat"
Addthefollowingtotheendofthefile/etc/network/interfacestorestoretheconfiguration
whenthenetworkinterfacecomesup:
upiptablesrestore</etc/iptables.ipv4.nat
Thefileshouldnowlooklike:
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
7/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
Atthispointtrytoreboottheraspberrypijusttomakesureeverythingworksasintended
youcanrebootwiththecommand:
sudoreboot
Hopefullyyouwillseeyournewaccesspointcomeonlineagain.Afteritcomesupagainyou
shouldbeabletoconnecttoitandaccesstheinternet!
Featured,Howto,Network,Projects,RaspberryPi,WiFi
Related posts
Introducing the Raspberry Pi 3 from the Raspberry Pi Foundation
NOOBSRaspberryPiOSinstallationmade
easy
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
HowTo:ShareafolderwithaWindowscomputer
fromaRaspberryPi
8/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
Stanley March19,2014at10:52am
Hiverycoolthingyoudidthere!ButIwouldliketoknowwhetherdoesthis
serveasanalternativetorouters?
ImlookingforapowerfulandyetlowpoweredwifirouterformyhousebutI
dontseemtofindanythatsatisfymyneedsIwasthinkingthatthe
raspberrypipowerwoulddothetrick.Doesthepiperformmuchbetterthan
thecommercialrouters?
admin April20,2014at10:33am
Intermsofwholehousecoveragethisisnotthewaytogo.
RememberthePionlyhaveasmallembeddedantennainitsWiFi
adapterthatwillnotgiveyouverygoodfullhousecoverage.
Emil April3,2014at5:34am
Canyouportforwardit?Andifso,how?
Mike April6,2014at8:01am
Hello
Ifollowedalltheaboveveryeasyinstructions,byfarthesimplestIvefound,
muchappreciated.However,unfortunatelyitwasnotsuccessful,Inoticed
therewereoneortwoerrorsflaggedasIwentthroughtheprocessbutthere
wasnothingIcoulddoaboutthematthetime.Pleasecanyousuggest
anywhereIcangetsometroubleshootingtipsfrom?
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
9/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
Manythanks
Mike
Cezary April14,2014at5:45pm
hello,istispossibletorunthatunderkernel3.10withraspbian?
Glen April20,2014at2:00am
Hi,
Isitpossibletosetuptheroutertoblockaccesstothelocalnetwork?Iwould
liketousethePIasaguestWiFiAccessPointsoIthereforeIwanttoblock
accesstomylocalnetwork.
karkar May3,2014at6:09pm
afterhitting
sudoserviceiscdhcpserverstart
sudoservicehostapdstart
igotthiserror..
Configurationfile:/etc/hostapd/hostapd.conf
drv>ifindex=3
l2_sock_recv==l2_sock_xmit=0x0x49648
ioctl[SIOCSIWMODE]:Invalidargument
Couldnotsetinterfacetomode(3)!
Couldnotsetinterfacetomastermode!
rtl871xdrvdriverinitializationfailed.
but..
mycellphoneandlaptopcanSTILLdetecttheSSIDofmyRaspberrypi..but
notabletoconnecttointernet..
whenigoogledthensomeonehadthesameissue..
https://groups.google.com/forum/#!topic/beagleboard/_bx0UlaFWjg
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
10/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
isitrequiredtoupgrademywifidongle??oranyissues??
pleasesolvemyissue
22decembre May7,2014at1:55am
Ihaveheardthat,duetohislowpower/performanceprofile,thePiisnota
goodideaasarouter.Yet,Ireallywouldliketodoso.
Question:istheactualresult(Piasarouter)good?Isitfast/efficient?
Doesitsupporttheloadwell?Fastnetworking?
Scooby June23,2014at7:35am
WhenIrun
sudoupdaterc.dhostapdenable
Iget
updaterc.d:error:norunlevelsymlinkstomodify,aborting!
AndwhenIrun
sudoupdaterc.discdhcpserverenable
Iget
insserv:warning:scriptmathkernelmissingLSBtagsandoverrides.
IamusingRaspbianWheezy20140107
Roy July4,2014at1:57am
Firstofall,thanks,greattutorial.IalsoaddedSamba,sonowitsevena
NAS.
Icanstreamoverthewifinetwork,aslongIalsoconnectanetworkcableto
it.
Ialsowannauseitifnonetworkcableisconnected,butIcantconnectto
thewifinetworkthen.
HowcanIchangethatsothatitalsocanbeusedasamobileNAS?
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
11/12
8/31/2016
HowTo:TurnARaspberryPiIntoAWiFiRouter|RaspberryPiHQ
Commentsareclosed.
Search
Categories
Advanced AirPlay ARM
BeginnerCasesFeaturedGettingStarted
HowtoNetworkProjectsRaspberryPiTop5ListsWiFi
Recent Posts
IntroducingtheRaspberryPi3fromtheRaspberryPiFoundation
Official7TouchscreenDisplayAvailablefortheRaspberryPi
HowTo:InstallWindows10IoTontheRaspberryPi
RaspberryP...
LikePage
Follow
147
ProudlypoweredbyWordPress|Theme:expoundbyKonstantinKovshenin|PrivacyPolicy|
RaspberryPiisatrademarkoftheRaspberryPiFoundation.
http://raspberrypihq.com/howtoturnaraspberrypiintoawifirouter/
12/12