0

I just yet starting to learn about web serving. So, far I know domain name is used for web page addresses (URL), like if we have an URL like this:

http://www.theaddress.thedomain.com/path/to/file.html
  • http:// is for protocol that is being used.
  • www is for hostname.
  • theaddress.thedomain.com is for domain name.
  • and so on.

But I confused when those terms are used in linux system. Like, when I try to install Apache2 on VirtualMachine and use it as server, i still can't use the hostname instead of typing my VM IP address to the web browser.

What are they doing in the system? Are those things matter when we don't use the linux as a web server? And is it possible to address the VirtualMachine with it's hostname and domain name? Or, those two only will be used when the server is going online?

1
  • everything has an ip address. the public internet has DNS resolving all the ip address to FQDN. Your local network can have that as some below mentioned. if it does they work the same
    – wlraider70
    Feb 2 '15 at 13:40
0

You would normally have to run a DNS server to get a domain name, which normally is not done for a personal VM. You can use the IP address of the VM to connect to it from inside your LAN, or localhost to connect to itself from within you VM. If you really want to, you can edit your hosts file on your box (not in the VM, but in the OS that is running the VM) to contain a custom hostname for your VM, basically, it'll map the hostname to the IP of the VM.

0

Without making things too complicated, your initial assumptions are correct.

You can give Machine-A a domain name but other machines on the network still need "someone" to translate that name into an IP if you try to ping it, most of the times that "someone" is the DNS server. Services exist to make this discovery automatic, i.e. let your machine broadcast it's hostname through a specific protocol but let's leave that aside for now.

In the case of a VM, another thing to remember is that VirtualBox for example will automatically put your VM in a LAN network, so by default your host machine is in a different network than your VM.

If you are playing with Apache inside a VM I suggest setting the network type of the VM to "bridged", that will allow it to behave like another machine on your same home network.

Regarding how to reach the VM from the host or any other machine in the same network (provided you've already set the bridged networking), you can register it in your home router, most of them will offer an option on their admin console to register hostnames.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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