Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to use the a custom URL name which is accessible from all devices in a LAN.

I know that it can be set in the /etc/hosts file

127.0.0.1   myname
127.0.1.1   system09-System-Product-Name

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

While entering the myname hosts it is available to access myname/urlpath . It is accessible only for my system. How can I make this available systems in my LAN too?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Localhost as its name says can only be accessed from your local system.

If you need other users to access yout custom URL you need to map your system IP address with the name used and then add this entry on all your LAN workstations by editing theirs /etc/hosts files for example:

127.0.0.1         <custom_name> # this is for localhost
<your_ip_address> <custom_name> # this is to be added to other workstations in the LAN

Other solution is to use a DNS server in your local LAN and create an A record for your custom name that will allow other users in you LAN to access your link.

share|improve this answer
    
192.168.1.16 sul - I updated in the host file but it is accessible to access sul/folder from my name system but not from another system which is in lan. Should i restart the system ? –  Explorer May 14 at 7:43
    
If you access this custom url from a remote lan machine you should type in your browser http:/sul/folder and if you added 192.168.1.16 sul in your remote machine /etc/hosts file it should work. I have tested your scenario now using a local Linux machine and a remote machine and can access the name sul from the remote machine web browser. There's no need to restart the system –  cioby23 May 14 at 7:59
    
It works without restart, Thank you –  Explorer May 14 at 8:15

The name localhost is only meant to be accessible locally.
On another note, you shouldn't remove localhost from /etc/hosts either. You will see lots of issues if you try and do so.

From this point you have 3 options.

  1. Create an entry in the /etc/hosts file of all the neighboring PCs
  2. Set up a DNS server on your network and add the entries to it. Most home routers have a built in DNS server/proxy, and many of those allow adding custom entries.
  3. Use mDNS. mDNS is part of zeroconf networking. It allows a machine to automatically resolve other hosts on the local network without having to manually configure a DNS server with those hosts. It does this by sending out a broadcast request, and waiting for a response.
    The exact procedure for setting it up varies by OS, but Arch Linux has a good guide.
     
    Once you have it running, all you have to do is refer to the neighboring hosts as foo.local (for a host called foo).
     
    This solution is cross plaform, as it is supported on both OS-X & Windows (and I think enabled by default on both as well).
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.