How to assign domain name to IP Address in Linux

Date:

How to assign domain in Linux

Assigning a domain name to an IP address in Linux involves a few steps, which are as follows:

1.

Edit the hosts file: Open the terminal and edit the /etc/hosts file using a text editor like nano or vi. This file contains the IP address and domain name mappings.

bash
sudo nano /etc/hosts

2.

Add an entry: Add a new line at the end of the file with the IP address and domain name that you want to assign. For example, to assign the domain name “example.com” to the IP address “192.168.1.100”, you would add the following line:

192.168.1.100 example.com

3.

Save the file: Save the changes to the file and exit the text editor.

4.

Clear the DNS cache: Clear the DNS cache on your system to ensure that the new mapping is used.

sudo systemctl restart nscd

or

sudo systemctl restart systemd-resolved

5.

Test the connection: Test the connection by pinging the domain name from the terminal.

ping example.com

If everything is configured correctly, the ping command should show the IP address that you assigned to the domain name.

How to assign domain in Linux

More Post

Thank you

Lucy
Lucy
Hello everyone

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Share post:

Popular

Related More like this