When developing a new website to replace an existing one, it’s common to have both sites simultaneously up and available – the old one for the public and the new one for the developers. Since you can only have 1 website behind any given URL, developers often build the new site under an alternate DNS name to ensure the paths remain the same; however, this can cause problems with software that isn’t tolerant to domain name changes.
Fortunately, if the new server has a different IP address from the old one, you can override DNS locally. This allows only the local computer to see the new site under the primary domain name while the rest of the world continues to see the old site. Also, because websites cannot determine for themselves what DNS name was used, they depend on the user’s browser to tell them which means this override carries over to the website as well.
All modern operating systems offer a file called the “hosts” files which you can use to set the domain to the new server’s IP while the rest of the world continues to see it as the old.
|Linux (all varieties)||/etc/hosts|
The format for the hosts file is the same regardless of the operating system. There will probably be some entries in it already – leave these alone as they are for the OS itself.
184.108.40.206 override.osu.edu override another.osu.edu
The 1st part is the IP address that you want the override to point to.
The 2nd part is a space-seperated list of DNS entries that you want pointed to the provided IP. These don’t need to be FQDN’s – you can add just the host name (the 1st part) to have it mimic something in your default DNS search path.
Any lines that start with a # are considered comments and ignored.
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 220.127.116.11 mysite.osu.edu mysite # Dev for mysite.osu.edu #18.104.22.168 another.osu.edu # Dev for another.osu.edu 127.0.0.1 localsite.osu.edu # A local web server 10.12.34.56 anotherlocal.osu.edu # Internal-use-only server
The localhost lines at the top are typical of what the operating system will require in this file. These should be ignored and any additions should go under them.
The 1st line above redirects all calls to either ‘mysite’ or ‘mysite.osu.edu’. DNS is never consulted so what it says those domain names should resolve to is irrelevant.
The 2nd line would do the same for ‘another.osu.edu’ except that it’s commented out. Also note that simply ‘another’ is not present so it would not be intercepted the same way ‘mysite’ would be above.
The 3rd line redirects all requests for ‘localsite.osu.edu’ to 127.0.0.1. This IP is called ‘localhost’ and is just a loopback that never leaves the computer. Services set to listen on 127.0.0.1 act like normal network servers but can’t be accessed by the outside so developers often set up local web servers on their desktops / laptops and access it through localhost. The hosts file can be used to intercept requests to the DNS name of the site being developed and route them through localhost instead.
The 4th line is common in larger development environments with dedicated development servers. The 10. network is among a few subnets designated as special cases for internal network use only. The Internet at-large will not relay traffic to/from a 10. IP – it’s immediately dropped. It’s important to note that with this setup that changing the hosts file is not enough – it also requires the developer be on the same local network as the server either physically or via a VPN tunnel.
Need More Information?
Is OSU Web Hosting right for you? Check your eligibility.
Ready to get started? Request hosting now!