How do I edit /etc/resolv.conf file in CentOS Linux?
You need to use the text editor such as vi / vim or joe make changes to /etc/resolv.conf file. You must be logged in as root user in order to change this file. The /etc/resolv.conf is resolver configuration file. You can set nameserver ip address and domain search query name in this file.
Edit File Using Vi or Joe Text Editor
Type the following command:
vi /etc/resolv.conf
OR
joe /etc/resolv.conf
Edit as follows and set name server IP address:
search dnsknowledge.com nameserver 69.9.190.5 nameserver 69.9.162.17
Save and close the file. Test new settings either with dig or host command:
dig google.com host google.com dig dnsknowledge.com
Thanks it was helpful!!
thanx a lot!
Thanks Bro,
How do you save and close?
Flynn , To save and close
follow this
#vi /etc/resolv.conf
PRESS INSERT on keyboar
To save
Press ESC on keyboard , then type
:wq
PRESS ENTER
Open file with vi editor
vi /etc/resolv.conf
Press button ‘i’ for insert mode
Make you changes
hit ESC button to goto ESC mode
Press shift+; in the keyboard
Now you can see the prompt like this
:
Enter ‘wq’ to save your changes
:wq
Press Enter
tnx so much
Thanks.
I did it.
Man, that took me FOREVER. Seemed to work though. Vi is definitely something I should take some more time to learn. Seems kind of powerful. Thanks again.
Yeah, I’m back here again. Do you think I may be having issues because in /run/resolvconf? I have a resolv.conf.swp (binary) and a resolv.conf I’d like to understand how to fix this. I’ll never give up. Thank you in advance for the help.
but with the help of vi /etc/resolv.conf not save perment data
I have centos 7 server on AWS its working fine and also sites are running well but my server not able to ping google.com or 8.8.8.8. May i know what i need to do for fix the issues.
traceroute google.com
traceroute to google.com (74.125.113.147), 30 hops max, 40 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *
18 * * *
19 * * *
20 * * *
21 * * *
22 * * *
23 * * *
24 * * *
25 * * *
26 * * *
27 * * *
28 * * *
29 * * *
30 * * *
very good