Stack Exchange Network

Stack Exchange network consists of 181 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How to set a domain to ip address?

You can reach this IP address 2.186.116.46 (if my computer is online). I want to assign a domain to it so I wonder how is that possible when I have no DNS? I do own my domain which is ".com". My IP is static.

wjandrea's user avatar

2 Answers 2

1. You need to acquire a domain name (or maybe just FQDN ) from some DNS provider .

2. Once you have registered the domain name, you will gain access to an administrative panel (like this one shown below), where you will be able (via A records), to redirect the domain name (and all *. or certain sub domains / FQDNs) to your server's IP address.

enter image description here

Please note that the provider's administrative panel shall looks different, and the provider will give you exact instructions how to use it.

Sometimes the redirection can take up-to 24 hours. You can check if it's successful by the command whois example.com .

If the server is behind NAT, you must setup port forwarding .

3. Edit your Virtual Host configuration file and add relevant ServerName and maybe ServerAlias directives. Let's assume the configuration file is 000-default.conf that should look as this:

This step can be omitted, but it is absolutely necessary when you have more than one Virtual Hosts .

Don't forgot to:

4. In addition for local needs :

You can bind a FQDN to the loopback interface of the server. For this purpose, edit the file /etc/hosts in a way like this:

It is not possible to enter *.example.com here. You can add an entry also for the IP address of another (local) server's network interface - for example 77.77.77.70 .

If you want to access the FQDN by another computer through the LAN (or by a private computer through Internet), edit its host file in a way like this:

Further reading:

Creating additional virtual host Ubuntu Server 16.04.3

Connect via ssh to one of the multiple clients on same network

PerlDuck's user avatar

If it is for just local use, you can just put that entry into your hosts file.

On modern Windows, that is usually c:\Windows\System32\Drivers\etc\hosts .

On Linux, the file is /etc/hosts .

For the rest of the world, use one of the freely available DNS providers.

Here is an example, with instructions: FreeDNS

Eliah Kagan's user avatar

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

Hot Network Questions

set domain name for ip address linux

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

Stack Exchange Network

Stack Exchange network consists of 181 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Change IP to domain name on linux

How is that we can convert an IP to a domain name address on linux machine.

Suppose i always access my Pc with http://127.0.0.1 from the browser

I want to change this to my.com

Zoredache's user avatar

3 Answers 3

you can add a line like

to /etc/hosts if you want to bind a hostname to an IP. In most default configurations this file is consulted first.

richo's user avatar

I'n not sure exactly what you're asking, but if you just want to know how to look up a domain name associated with an IP address, you can use dig -x to do a reverse DNS lookup :

Note that this won't always work, because there may be multiple domain names pointing at a single IP address, and it's not always the case that every IP address has a reverse DNS mapping.

Brian Campbell's user avatar

You should already be able to access that via http://localhost/ , which is the standard name for 'this machine'.

Andrew McGregor's user avatar

Your Answer

Sign up or log in, post as a guest.

Required, but never shown

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 linux ip domain-name or ask your own question .

Hot Network Questions

set domain name for ip address linux

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

How to use the Linux BIND command to install and configure DNS

%t min read | by Ashish Bharadwaj Madabhushana (Red Hat)

Compass

Photo by  Alexander Andrews on Unsplash

The Domain Name System (DNS) is used to resolve (translate) hostnames to internet protocol (IP) addresses and vice versa. A DNS server, also known as a nameserver , maps IP addresses to hostnames or domain names.

In this article, you will learn the basics of DNS, from how DNS gets the IP address and hostname, to the concepts of forward and reverse lookup zones. It will also show you how to install and configure DNS, define and edit zone files, and verify whether the DNS can resolve to the correct address with the help of commands. If you are new to DNS, this article will help you play with it on your system using basic configurations.

How DNS works

When a client requests information from a nameserver, it usually connects to port 53, and then the nameserver resolves the name requested.

DNS lookup request and response between client and server

Where does DNS get IP addresses?

You might wonder how DNS gets the IP of the corresponding hostname or domain name. How does DNS search among different IP addresses and associate your domain name correctly? Who stores those mappings between domain names and IP addresses?

The DNS workflow illustrates how communication happens within DNS and how it resolves the addresses.

DNS workflow

[ Download now:  A system administrator's guide to IT automation . ]

Forward and reverse lookups

The forward lookup zone uses the domain name to search for IP addresses, whereas the reverse lookup zone uses IP addresses to search for the domain name.

forward and reverse lookup process

Install and configure DNS

BIND is a nameserver service responsible for performing domain-name-to-IP conversion on Linux-based DNS servers.

The BIND package provides the named service. It reads the configuration from the /etc/named and /etc/named.conf files. Once this package is installed, you can start configuring DNS.

Configure the /etc/named.conf file

First, add or edit the two values in the options field. One is the DNS server address, and the other is the allow-query to any .

Here are the values from the above file:

Define the forward and reverse zones

Define the forward and reverse zones in the /etc/named.conf or /etc/named.rfc1912.zones (you can define zones in either of those files). In this example, I am appending zone definition details to the /etc/named.rfc1912.zones file.

Create forward and reverse zone files

You also need to create forward and reverse zone files in the /var/named directory.

Note : By default, the named.conf file includes the /var/named directory for checking zone files. Sample zone files named.localhost and named.loopback are created during the installation of the BIND package.

a forward lookup zone

Add the nameserver IP to /etc/resolv.conf

First, you must disable DNS processing by NetworkManager because it dynamically updates the /etc/resolv.conf file with DNS settings from its active connection profiles. To disable this and allow manual editing of  /etc/resolv.conf , you must create a file (For example,  90-dns-none.conf ), as root in the /etc/NetworkManager/conf.d/ directory that contains the following:

Save the file and reload (restart) NetworkManager.

After you reload NetworkManager, it won't update  /etc/resolv.conf . Now, you can manually add the nameserver's IP address to the /etc/resolv.conf file.

[ Be prepared in case something goes wrong. Read An introduction to DNS troubleshooting . ]

Start/restart and enable the named service

If the named service is not running or is disabled, then start and enable it. If it is already active (running) and you made all these configurations, you need to restart the service to make changes.

Verify the DNS name resolution

You have installed the BIND package, configured named files, created lookup zones, and restarted the service to make configurations take effect. Now use the nslookup and dig commands to check whether DNS is working properly and verify whether you are getting the intended results.

Query with nslookup

Query with dig.

Here is a forward lookup, where DNS responds with 192.168.11.132 as an IP for servera.example.com :

This example displays a reverse lookup, where the DNS server responds with servera.example.com as the domain name for 192.168.25.132 :

[ Network getting out of control? Check out Network automation for everyone , a free book from Red Hat. ]

In this article, you learned what DNS is and how it works. Also, you now know what forward and reverse lookup zones are and how they work. You also learned how to install the BIND package, which is responsible for setting up DNS on the system and configuring the named files and lookup zones. Finally, you learned two commands, nslookup and dig , to interrogate DNS resolutions.

Check out these related articles on Enable Sysadmin

Earth

Ashish Bharadwaj Madabhushana

Ashish Bharadwaj is an intern at Red Hat who is passionate about systems administration, networking, and programming.  Ashish believes open source is the future and that contributing to the technologies and community is a great way to solve problems efficiently and create new ideas or products. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the red hat developer program., related content.

How to enter the world of Linux containers

OUR BEST CONTENT, DELIVERED TO YOUR INBOX

Privacy Statement

Related blogs

How to install free SSL certificate on Nginx web server

How to host a website on Github for free with a custom domain?

How to install Nginx on Red Hat Linux server?

How to build a CLI Tool using Python ?

User guide for deploying the Next.js app in production using PM2 and Nginx?

How to set up a virtual Host on an Nginx?

How to configure Tailwind CSS with Next js ?

How to configure Tailwind CSS with React ?

How to install an Elastic Enterprise Search (Appsearch) on Ubuntu?

How to install Nginx on an Ubuntu server?

How to configure Elasticsearch and Kibana setup

How to Map a domain name with a Linux server using public IP?

2022-10-17T09:33:34.650973Z

Published on

How to Map a domain name with a Linux server using public IP?

Introduction:

If you have not changed any dns settings after purchasing your domain. then by default, your domain name will be in a parked state . that means when you visit your domain name it will redirect to some sample page without showing a blank page. to change the state of your domain name from parked state to live state . you have to delete an a record ( with fields mentioned as parked on it ) from the dns settings. to read more about dns records click here ., flow diagram:.

flow diagram

Prerequisites:

Purchased domain name linux server with public ip address, step 1: retrieve the public ip address of the linux server., navigate to the dashboard of your linux server and get the public ip address of the server., step 2: navigate to the dns settings of the respective domain name., login to the domain provider account navigate to the dns settings of the respective domain name. note:* in this article, godaddy is used as a domain name provider.  , step 3: if your newly purchased domain is parked by default, delete the a record.,   delete the a record ( with fields mentioned as parked on it ) from the dns settings. for your reference an example screenshot is given below, in this example the domain name provider is godaddy., step 4: create a new a record to link the linux server ip with the domain name., note:* in this article, godaddy is used as a domain name provider. to link your domain name with the linux server ip . create an a record , as shown in the below screenshot. type: a name: @ value: 0.0.0.0 ( enter your linux server ip address, eg: 53.253.23.125 ) ttl: default, note:* to check whether the domain name is linked to the linux server ip, please follow the below steps. install nginx on ubuntu 1 sudo apt update 2 sudo apt install nginx -y copy copy copy copy copy copy copy copy copy copy copy   check nginx status by executing the below command, if the status is running you’re ready to go. 1 systemctl status nginx copy copy copy copy copy copy copy copy copy copy copy an example output screenshot is given below. check your domain name is linked to the linux server, by visiting the domain name from a web browser. an example output screenshot is given below..

interested topics

Subscribe to our Newsletter

The latest news, blogs, and fun memes from the community!

circle logo

Copyright @2022 Episyche Technologies Pvt Ltd

set domain name for ip address linux

How to get a hostname/domain name from an IP address in Linux

In this short guide, we have explored a few ways to performs Reverse DNS lookup and get a domain name from an IP address. For demonstration purposes, I have used Ubuntu 20.04.

Prerequisites

Before you roll up your sleeves, ensure that your remote host has an A record which is a DNS entry that points or maps a domain name to an IP address

Perform DNS Reverse lookup using dig command

Dig command is a flexible and powerful tool that is used for querying or probing DNS records. It’s an acronym for domain information groper and allows you to retrieve a wide array of DNS information such as A, CNAME, MX, and SOA records.

set domain name for ip address linux

Perform DNS Reverse lookup using nslookup command

A nslookup command is a troubleshooting tool that features highly in a sysadmin’s armory. It’s a versatile tool that performs all DNS record querying such as CNAME, A, MX, and reverses or PTR records.

To retrieve a domain name from an IP address, use the command syntax:

For example.

set domain name for ip address linux

Perform DNS Reverse lookup using the host command

Similarly, you can use the host command to obtain a hostname or domain name from an IP address using the syntax as shown.

For example, to check the domain name for the IP 5.9.235.235, execute the command:

set domain name for ip address linux

Just like the Nslookup command, you can also use the host command with hostnames or IP addresses.

The few examples that we have just elaborated are a sure way of helping you obtain the domain name from an IP address. Usually, the reverse DNS lookup is trivial and not as crucial as the forward lookup, which maps domain names to IP addresses. Your feedback or contribution will be highly welcomed.

About the author

set domain name for ip address linux

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays .

Related Articles

Creating custom domain name instead of localhost in Ubuntu

In ubuntu, the local server by default is referred by the name “localhost”. However, you can also create a custom domain name for your local server instead of using localhost . This article explains the process to create your own custom domain name instead of using localhost . Here ‘hackdx.md’ is created as our domain, which can be taken as per need.

Note: This article is compiled focusing on Linux users but the process is similar for windows user with some minor changes.

Below are the steps to create your own custom domain name instead of using localhost, in Ubuntu :

sudo apt-get update sudo apt-get install apache2 php

You can check your server by typing ‘localhost’ into your browser. If you get apache ubuntu default page i.e you have successfully installed apache2 server.

sudo apt-get install xed
sudo xed /etc/hosts

This can be done with the below command:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/hackdx.md.conf
sudo xed /etc/apache2/sites-available/hackdx.md.conf
sudo a2dissite 000-default.conf sudo a2ensite hackdx.md.conf sudo systemctl reload apache2

Run this command to edit apache2.conf

sudo xed /etc/apache2/apache2.conf

Add these lines to your apache2.conf file as given in the figure.

sudo systemctl reload apache2

Now you can put your files in www directory and enjoy using the PHP server.

Please Login to comment...

Improve your Coding Skills with Practice

Start your coding journey now.

IMAGES

  1. How to Set Hostname Fully Qualified Domain Name FQDN on Ubuntu linux

    set domain name for ip address linux

  2. Set IP Address in Linux

    set domain name for ip address linux

  3. How to Find IP Address in Linux [Step-by-Step]

    set domain name for ip address linux

  4. How to get a hostname/domain name from an IP address in Linux

    set domain name for ip address linux

  5. How to get a hostname/domain name from an IP address in Linux

    set domain name for ip address linux

  6. .net

    set domain name for ip address linux

VIDEO

  1. How to set hostname in CentOS

  2. IN 20 DOMAIN NAME AND IP ADDRESSING

  3. Configuring DNS Name Sever in Ubuntu 18.04

  4. Day-10 Set hostname and configure domain alias in Linux OS (Explain in Hindi)

  5. How to Set A Static IP Address on Linux

  6. Hostnames and IP Addresses

COMMENTS

  1. How to set a domain to ip address?

    1. You need to acquire a domain name (or maybe just FQDN) from some DNS provider. 2. Once you have registered the domain name, you will gain

  2. Linux Commands to Translate Domain Name to IP

    The host command is a DNS lookup utility used to convert domain names to IP addresses and reverse IP lookup. The command comes preinstalled with

  3. Setting up the domain name

    Procedure · If the entry for localhost in /etc/hosts as follows: 127.0.0.1 <hostname>.<domainname> <hostname> localhost.localdomain localhost. Change the

  4. Change IP to domain name on linux

    I'n not sure exactly what you're asking, but if you just want to know how to look up a domain name associated with an IP address, you can use dig -x to do a

  5. How to use the Linux BIND command to install and configure DNS

    Configure the /etc/named.conf file · Define the forward and reverse zones · Create forward and reverse zone files · Add the nameserver IP to /etc/resolv.conf.

  6. How to assign an IP address to a domain in Linux

    Go to your router, go to DHCP settings, find 'address range' and change it from 192.168.0.1–255 to 192.168.2.1–255. You will have to reboot or reconnect all

  7. How to Map a domain name with a Linux server using public IP?

    If you want to access your website with a domain name rather than an IP address which is ... How to set up a virtual Host on an Nginx?

  8. How to get a hostname/domain name from an IP address in Linux

    One of the questions that many Linux users ask is how they can retrieve a system's hostname using its IP address. It may seem an uphill task

  9. Creating custom domain name instead of localhost in Ubuntu

    Install 'xed' if not already done using: sudo apt-get install xed · Then Execute this command to edit the hosts file. sudo xed /etc/hosts · Enter

  10. Setting up Name to Address Resolution (DNS)

    When you make a PPP connection, you need to tell your Linux machine where it can get host name to IP number (address resolution) information so that you can use