You are on page 1of 4

9/7/2016

AccessingWebsitesonaLocalNetwork(LAN)WebServer|DeveloperSide.NET

AccessingWebsitesonaLocal
Network(LAN)WebServer
Thereareanumberofdifferentwaysthatlocalwebsitescanbeviewedfromothercomputers
(runningWindows,MacOSX,Linux)andmobiledevices(iPads,iPhones,Androidphones,etc),
thatareallconnectedwithinthesameLAN(localnetwork).
TogeteveryLANconnectedcomputerandmobiledevicetofindandconnecttoalocalwebsite,
youhavetheseoptions:

UsetheLANIPofServer
ConnectdirectlytotheserverviaitsLANIPaddress,usingthatIPintheURL:
http://192.168.1.100/
Forthistowork,theLANIPaddressmustbeassignedasoneofthewebsitesDomainAliases,and
allredirectsfromAliasestothePrimaryDomainNamemustbeturnedoff.
Downsideasonly1IPaddressisassignedperNIC(networkcard),only1websitecanbe
accessed.

UsetheLANhostnameofServer
ConnecttotheserverviaitsLANhostname(computername),usingthathostnameintheURL:
http://computername/
Forthistowork,theLANhostnamemustbeassignedasoneofthewebsitesDomainAliases,and
allredirectsfromAliasestothePrimaryDomainNamemustbeturnedoff.
Downsideasonly1hostname(computername)isassignedpercomputer,only1websitecanbe
accessed.Also,theremightbeissueswithsomenonWindowsdevices,suchastheiPad,which
eitherdontinteroperate(workwith)WINSandNetBIOSorrequirefurtherconfiguration.

UseaLANwideHostsfileSetUp
https://www.devside.net/wampserver/accessingwebsitesonalocalnetworklanwebserver

1/4

9/7/2016

AccessingWebsitesonaLocalNetwork(LAN)WebServer|DeveloperSide.NET

ConnecttotheserverbyusingLANwide(global)Hostsfiles
ThisisdonebyeditingeveryLANsystemsHostsfilewithentriesthatresolveeachandevery
websitesdomainnameandaliasestotheLANIPoftheserver:

192.168.1.100www.domain1.namedomain1.alias1domain1.alias2
192.168.1.100www.domain2.namedomain2.alias1domain2.alias2
192.168.1.100www.domain3.namedomain3.alias1domain3.alias2
ThiswayalltheotherLANsystemsknowtowhichIPaddresstosendtherequesttowhen
thewww.domain.nameisusedinthelocalBrowser.
DownsidewhilethiswillworkonWindows,Linux,andMacOSX,thiswillnotworkonmost
mobiledevicesunlesstheyarejailbroken/rooted(asyoucantedittheirHostsfile).
Hostsfilepath:C:\Windows\system32\drivers\etc\hosts

UseRegisteredDomainNames
Connectviaanywebsitesdomainname,aslongasthatdomainnameis:
Registered(boughtandpaidforonNamecheap,GoDaddy,etc)
AndhasaDNSArecordset(resolved)toeithertheLANIPoftheserver(ex:192.168.1.100)
orthePublicIPoftheRouter(viathedomainRegistrarsDNSservers).
*ItsperfectlyvalidtoresolveadomainnametoalocalLANIPaddress.
Ifyouonlyhave1registereddomainname,youcanuseitssubdomainstorepresentyour
differentlocalwebsites,byusingawildcard(*)/catchallDNSrecord.Thisway
all*.domain.namerequests,regardlessofwhattheyare,willalwaysberesolvedtoyourLANIP
orPublicIP.Andoncethatrequestreachesyourwebserver,thewebserverwillmatch
thesub.domain.nametotheproperwebsite.Thedownsideofthisisthateverywebsitesdomain
namemustuseacommonbase(whichcanmakethefulladdresslong).

UseaWiFiRouterthatscapableofDNS
Masquerading
SomeRoutersaresupportedby3rdpartyfirmwaresuchastheOpenWRTandDDWRT(2)
projects.

https://www.devside.net/wampserver/accessingwebsitesonalocalnetworklanwebserver

2/4

9/7/2016

AccessingWebsitesonaLocalNetwork(LAN)WebServer|DeveloperSide.NET

BothOpenWRTandDDWRTareabletoinjectcustomdomainnametoIPaddressresolvesvia
theirowninternalHostsfilesand/orinternalbundledDNSMasqueradingsoftwaresuchas
DNSmasq.
ThisisprobablythebestoptionasALLWiFiconnectedcomputers(regardlessofOS)andmobile
devices(everythingfromiPadstoAndroidphones)willbeabletoconnecttoeachandevery
websiteWithoutconfiguringanythingordoinganythingtothosecomputersanddevices.

UseOwnDNSServers
Localnetworks(thatarebehindatypicalwifiRouter)useoutsideDNSservers,whichresolve
(convert)domainnamestoIPaddresses.
Typically,theRoutergetstheaddressesof24DNSserversfromyourInternetProvider(viaa
protocolcalledDHCP),andactsasthemiddleman,fordomainnameresolverequests,between
thecomputersanddeviceswithintheLAN,andtheexternalDNSservers.
TheseexternalDNSserversareunabletoanswerandresolverequestsforyourvirtual(non
registered)domainnamestoyourlocallyhostedwebsitesandtheirLANIPs.
Youcanhowever,viayourRoutersettings,switchovertheseDNSserverswithyourownlocal
DNSserver,whichwillbeabletoresolveallvirtual(fake)domainnames,andwildcards(ex:
*.local),totheserversLANIPaddress.
ThereareseveraloptionsforDNSServersforWindows,andLinux.

Notes
Onsomemobiledevices,youcansetthemtouseanHTTPProxyserver,thatwillthencustom
resolvethedomainnametotheLANIPaddress.Thisgetsaroundtheproblemofnotbeingableto
editthedevicesHostsfilewithoutjailbreakingorrootingit.Butyoullneedonecomputer
runningtheproxyserversoftware.OnWindows,youcanusetheFiddlerProxytosetthisup.
MobiledeviceshavetobeconnectedtoyourWiFitobeabletoaccesstheserverviatheLANIP
address.Otherwise,youmustusearegistereddomainnamethathasaDNSrecordresolvingthe
domainnametothethePublicIPoftheRouter(whichthenportforwardsfromWAN:80to
LAN:80ofserver).
LANIPsareusuallyreassigned/changedafterrebootorpoweroffoftheLANconnected
computersanddevicesand/ortheRouter.YoullhavetogointotheRoutersconfigurationand
settings,andmakesuretomanuallyassignthesameLANIPtothesameLANsystem(by
assigningthatLANIPtotheserversMACaddress).
WhenarequestcomesintothewebserverforadomainnameorIPaddressthatisnotassignedto
anywebsite,thefirstApacheVirtualHost(DefaultWebsite,localhost)getsreturned.
https://www.devside.net/wampserver/accessingwebsitesonalocalnetworklanwebserver

3/4

9/7/2016

AccessingWebsitesonaLocalNetwork(LAN)WebServer|DeveloperSide.NET

WhenaccessingtheserverdirectlyviaanIPaddress,youllonlybeabletoaccess1website(the
websitethathasthatIPassignedasaDomainAlias)Unlessyouruneachwebsiteonaseparate
portnumber(8080,8081,etc).*SomeApacheconfigurations/setupsandsomePHPwebapp
scriptsmightnotworkcorrectly,astheyexpectregularport80access.
Whilemostmobiledevices(includingiOSandAndroiddevices)haveaHostsfile,thosedevices
havetobejailbroken/rooted,and/oryouhavetogothroughcomplicatedstepstomodifytheir
Hostsfile.*IfyouedittheHostsfile,makesureyousaveitinitsoriginalencoding:ANSI.
RunningyourownDNSserverisnotrecommendedasitcouldbecomplicatedtosetupand
operate,andthesystemitsonhastoalwaysbeOnforeverythingelsetowork.Ifyoudorunyour
ownDNS,youllneedtosetitsLANIPintheRouterssettingsandmakesurenootherDNS
serversareused(bytheRouter).DNSMasqistherecommendedchoice.
Youcanhostmultiplewebsitesunder1maindomainname/websitebytreatingtheotherwebsites
asfolders:C:\WampDeveloper\Websites\main.domain.name\webroot\other.domain\
http://en.wikipedia.org/wiki/Hosts_(file)
HowdoImodifymyhostsfile?
*MakesuretoturnoffanyredirectsoftheDomainAliasestothePrimaryDomainName(*select
websiteinWampDevelopersWebsitesTab,clickSettingsorjustcreateawebsitewiththeLAN
hostnameasthePrimaryDomainName,andtheLANIPasoneoftheDomainAliases).
*Makesuretoopen(onthewebserver)theWindowsFirewallinboundport80(http)and443
(https)connections(TCPandUDP).WindowsFirewallwillblockthesebydefault.
*IfyouareresolvingdomainnamestothePublicIP(oftheRouter),makesuretoupdatethe
Routerssettingstoportforwardincomingport80(http)and443(https)requeststotheproper
LANIPofthewebserver.

https://www.devside.net/wampserver/accessingwebsitesonalocalnetworklanwebserver

4/4

You might also like