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:
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
).
Open the /etc/resolv.conf
file in a text editor:
sudo nano /etc/resolv.conf
nameserver 8.8.8.8 nameserver 8.8.4.4
Save the file and exit the text editor.
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.