Dns – Mapping domain name with local IP address

dnsdomain-nameip

On a local machine I can map my machine IP address with some domain like below:

127.0.0.1       testwebsite.com

My question is once I get a domain name (say testwebsite.com) from a domain name provider, can I say to them "map it to my machine IP address where my web application is deployed" or does it have to be deployed on their environment?

Also, do I have to provide this mapping at the time of the domain registration or can it be done later as well?

Best Answer

A domain such as example.com has various records, such as the A record and MX records.

These records redirect traffic to a location. Where that location is doesn't matter.

If you setup the A record for example.com to point to your public IP address (the ip address provided by your ISP) then anyone who enters example.com can find its route to your modem.

It is then up to your modem to tell the traffic where to go next. If your modem is not also a router, the modem will simply redirect everything to the router behind it. The router then needs to have a port mapping that tells where the traffic needs to go to.

Given that websites use HTTP traffic, which by default is set to port 80, you need to forward port 80 to the local ip address where the webserver is located. If you host the webserver on your own computer, then you setup port 80 to the ip address of your local computer.

That said, this will continue to work until your IP address changes. If that happens you need to update your domain's A record to point to the new IP address. There are services that allow you to do this for you, but bringing your own domain is often a premium feature. In addition, using your own webserver at home means that you will lose internet speed.

If these problems are something you want to avoid, it is probably going to be cheaper to get a cheap webhosting. Most of the time, they include a free domain too.

That said, to answer your questions:

My question is Once I get domain name (say testWebsite.com) from domain name providers, Can i say them map it to my machine IP address where web application is deployed or it has to be deployed on their environment ?

You can map it to anything, including your own ip address, as long as you have control of DNS records (this is something you need to make sure, in case you go for webhosting + domain. If you only go for a domain, it is always going to provide DNS management.)

Also Do I ahve to provide this mapping at the time of domain registration or it can be done later as well ?

No, you do not have to provide this mapping at the time of the registration. Until you do, the domain will simply not forward or more likely forward to the website of the registration party. You can change it at any time if you please to whatever you want. Keep in mind that changing DNS takes time. You change it instantly at the location of the provider, but other DNS servers must then query and update the records. Given that there are over a million of DNS servers all around the world, it can take up to an hour before the changes are processed in your contry, and up to 48 hours until it is done all over the world.

Related Question