0% found this document useful (0 votes)
607 views

Accessing Websites On A Local Network (LAN) Web Server - DeveloperSide

There are several ways to access local websites from computers and devices connected to the same local network (LAN). Methods include using the LAN IP address of the server, the LAN hostname, setting up a LAN-wide hosts file, using registered domain names resolved to the LAN IP, using a router capable of DNS masquerading, running your own DNS servers, or setting up an HTTP proxy. Each method has advantages and disadvantages, such as only being able to access one website per IP/hostname or not working for some devices without modifications.

Uploaded by

bungteka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
607 views

Accessing Websites On A Local Network (LAN) Web Server - DeveloperSide

There are several ways to access local websites from computers and devices connected to the same local network (LAN). Methods include using the LAN IP address of the server, the LAN hostname, setting up a LAN-wide hosts file, using registered domain names resolved to the LAN IP, using a router capable of DNS masquerading, running your own DNS servers, or setting up an HTTP proxy. Each method has advantages and disadvantages, such as only being able to access one website per IP/hostname or not working for some devices without modifications.

Uploaded by

bungteka
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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