How to Set Up DNS Lookup in Linux

How to Set Up DNS Lookup in Linux

To set up DNS lookup in Linux, you will need to configure the /etc/resolv.conf file. This file contains a list of nameservers that the system uses to resolve domain names.

Here are the steps to set up DNS lookup in Linux:

  1. Determine the nameservers that you want to use. These can be provided by your Internet service provider, or you can use a public nameserver such as Google's DNS (8.8.8.8 and 8.8.4.4).

  2. Open the /etc/resolv.conf file in a text editor:

‮r‬efer to:lautturi.com
sudo nano /etc/resolv.conf
  1. Add the nameservers to the file. For example, to use Google's DNS, you can add the following lines to the file:
nameserver 8.8.8.8
nameserver 8.8.4.4
  1. Save the file and exit the text editor.

  2. Test the DNS lookup by running the nslookup command. For example, to look up the IP address of google.com, you can use the following command:

nslookup google.com

If the DNS lookup is successful, the nslookup command will display the IP address of google.com.

Keep in mind that the /etc/resolv.conf file is overwritten every time the network interface is brought up, so you will need to configure the nameservers every time the network interface is restarted.

To make the changes permanent, you can configure the nameservers using the Network Manager utility or by modifying the network configuration files.

Created Time:2017-10-29 22:08:35  Author:lautturi