Score:0

Access server on local area network with hostname instead of IP address

um flag

New to ubuntu and servers. I just finished installing a new ubuntu server and added LAMP. I can assess the webpage that I am hosting by typing in the web browser the IP address of the server. what I would like to know is how to access the same web page locally on my network from another computer using a name instead of the IP address.

I have tried to edit the /etc/hosts and add the following info: "192.168.0.205 servername". this does not work when I type "http://servername" in a web browser I do not connect.

I have been looking for an answer but am not sure I am describing what I want to do because most of the solutions seem to assume that I want to connect from outside my network. I am not interested in accessing my server from outside the local area network at this time until I am more comfortable with managing the server and understand the security risk.

Thank you in advance for any info you can provide to help me with this issue.

EODCraft Staff avatar
cn flag
Pretty sure hostname would need port for page also. `hostname:port`
Score:0
in flag

There are three (relatively simple) options for you to choose from:

Option 1 – .local

If your Ubuntu installation is announcing itself on the network (which it does by default), then you should be able to access it using the {host}.local domain name. This is OS independent, which means you'll be able to connect from devices running Windows, Mac, Android, iOS, or most other operating systems created after 1993.

For example, here are some systems on my home network:

Server Name URL
carbon http://carbon.local
w541 http://w541.local
t495 http://t495.local

These names are not very imaginative, but they get the job done.

Option 2 – /etc/hosts on all network devices

If all of the machines on the network are running Ubuntu (or some form of Linux), then you could also resolve the issue by updating the /etc/hosts file on each other those machines to include a line for your server. This would allow you to set the domain name to be anything.

Option 3 – Local IPs on Personal Domains

Alternatively, if you have a domain name, you could set up DNS A records for subdomains that point to servers on your local network.

For example:

Domain A Record
robert.com 54.xxx.yyy.zzz
nextcloud.robert.com 192.168.0.205

This would allow the devices on the home network to use the DNS provider they're already configured to use, and connections would only be possible when on the network (otherwise they time out).


Of the three options listed, the first may make the most sense unless you're looking for something really specific.

robert avatar
um flag
Option one works perfectly, thanks for taking the time to explain this.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.