Set up a website on my internal network and access it with a domain name instead of IP

34,187

BIND is a DNS server. (The ND means "Name daemon", which is a Unix-ish way of saying "name server".)

You can have BIND tell any device, including the laptop (and including the server), that mynet.home has an "A record" of 192.168.2.3

You seem to have understood all of that (vaguely, at least). Then you'll want to make sure that your computers (the laptop, and the server) send DNS queries to 192.168.2.3

One way to do that is to specify which system to query. e.g.:

nslookup mynet.home 192.168.2.3

A better way is to make the default location for DNS queries to be the server. Rotunduh's comment describes that. The most traditional way for Unix-ish systems is to adjust /etc/resolv.conf and include lines like:

nameserver 192.168.2.3
search mynet.home

Then you can simply use: nslookup mynet.home

You should also be able to ping (unless ping is unsupported, such as if a firewall blocks standard ping traffic). e.g., ping mynet.home

You should then be able to reach your webserver at http://mynet.home

Your web server might not show you the desired web pages until the web server is configured to recognize "mynet.home" as a domain name that it responds to.

So there's a few steps in the process:

  • set up DNS server (e.g. BIND)
  • set up network configuration to specify where DNS queries go to
  • set up web server to support the domain

That's not including testing, or handling any difficulties like firewalls blocking traffic. So I submit this answer as a brief overview, with the expectations that one or more of these steps may be complex enough that you may have additional struggles/questions while setting all this up. Hopefully this roadmap gives you enough guidance to know what direction you're trying to head. (If you have additional specific questions, please make some new questions.)

(Of course, I'm not trying to suggest anything other than following the standard recommended process: check for documentation, online tutorials, etc., and then ask away if things remain unclear.)

Note: I'm not trying to disagree with other answers, which say things like using /etc/hosts and/or adjusting a router's configuration. I'm not trying to say that other approaches, referenced by other answers, won't work. There are multiple possible designs that can work. In fact, I would even say that those other approaches might be the fastest way (in the short term). However, using BIND, as you suggest, is more similar to professional setups like what is common on public Internet servers. And using BIND ought to work fine. You seemed to be asking about that approach, so that is what my guide is trying to describe.

Share:
34,187

Related videos on Youtube

Rotunduh
Author by

Rotunduh

Updated on September 18, 2022

Comments

  • Rotunduh
    Rotunduh over 1 year

    I have a small local network, with the following devices: a Belkin n150 router (older generation), a Dell laptop running Ubuntu 14.04 LTS (GNU-Linux 3.13.0-24-generic x86_64) as my server, and another HP laptop to test access.

    My IP addresses look like this:

    • router: 192.168.2.1
    • server: 192.168.2.3
    • laptop: 192.168.2.2

    I have successfully setup LAMP and have one small page (/var/www/html/index.html) with one picture.

    I can access this from my HP laptop by entering 192.168.2.3 into Firefox or Chrome.

    I attempted to setup DNS using BIND9, following this tutorial. I followed the tutorial verbatim and then spent time looking at other videos and forums as well, but after several hours of trying, it still isn't working.

    How do you redirect a domain name (ie. http://mynet.home) to access the website on a local server (192.168.2.3)?

    • Paul
      Paul almost 10 years
      What DNS server are you using currently? It it your router? If so, what model is it?
    • Rotunduh
      Rotunduh almost 10 years
      I guess I was only using bind9 (as I understood it I could run both a dns and the apache site from the same box no?) should i have installed dns from tasksel? my router amazon.com/Belkin-Connect-Wireless-Generation-F7D5301/dp/… only has dyndns settings and doesnt support openwrt or the likes
    • Paul
      Paul almost 10 years
      I mean right now, where does ubuntu get its dns resolution from? If you look in /etc/resolv.conf what name servers are defined? Is it your router or something on the internet or something else?
    • Rotunduh
      Rotunduh almost 10 years
      Its strictly internal, so no internet. the resolv.conf file: nameserver 192.168.2.3 (which is the ubuntu server) search mynet.home
  • Rotunduh
    Rotunduh almost 10 years
    That is a good step by step but that is the method where you need to edit the host file on each computer for it to access the vhosts. Is there a way around that? for instance if a friend came over and access my internal network and looked up mynet.home without having to edit the host file on his pc
  • Grant
    Grant almost 10 years
    Then you'll need a DNS service, and since your router doesn't support it you'll have to set it up on your Ubuntu server. Avahi seems to be a popular one. Never done it myself though.
  • Rotunduh
    Rotunduh almost 10 years
    But I'm not looking to access it via the internet, only on my local connection being provided by my router (with no wan access)
  • AFH
    AFH almost 10 years
    I took mynet.home to indicate a public internet address. Within your intranet all you need do is fix the HTTP server address in your router and add the entry 192.168.2.3 mynet.home to /etc/hosts in each client that needs to access it.
  • Rotunduh
    Rotunduh almost 10 years
    Okay thank you AFH, I was wondering if there is a way around that, so that each new client wouldn't need to edit the host file but without a better router it doesn't look like it can be done the way I originally thought. Thanks for taking the time to reply, I appreciate it! =)
  • AFH
    AFH almost 10 years
    The router is not a limitation: if it does not allow fixing an IP to a MAC within its DHCP service, you can set up a 192.168.2.* address manually in the HTTP server, but make sure it is outside the router's DHCP range - I do this on my servers in both Windows and Ubuntu. You can set up a DNS server in your intranet, but this seems overkill, and a lot more work than editing a few text files. DNS ought to be provided by routers, but I haven't bought one which has it.
  • davidgo
    davidgo over 8 years
    @AFH the router is absolutely a limitation as in order for this to "just work" it needs a DNS entry - and the Belkin will be acting as a DNS router/proxy.
  • AFH
    AFH over 8 years
    Routers do not normally provide DNS for the local network, so you will need another machine to act as a DNS server. You should be able to do this with appropriate software on the HTTP server.