Share & learn

Through Innovative Digital Library

How to find and replace resolv.conf name server ip address with sed command?

How to find and replace resolv.conf name server ip address with sed command? How to change the name server ip address by using sed command?
 



Answers

Posted by chandu on December 12th 2017 08:49 AM

The /etc/resolv.conf file is used for DNS client server, to determine both master and slave servers. If you want to replace resolv.conf name server ip address by using sed command. Use the following command to replace name server ip address: Syntax: # sed -i -- 's/oldip/newip/g' /etc/resolv.conf The -i option is used to edit the /etc/resolv.conf the “g” at the end tells sed to perform the action globally. The -- serves to tell sed .This is useful to protect against file names starting with -. Fisrt check the resolv.conf file to know name server ip address by using following command:

#  cat /etc/resolv.conf

Posted by chandu on December 12th 2017 08:51 AM

It will display the name server ip addresses Current ip 192.168.15.2 New ip 192.168.15.3 Now I am replacing the name server ip address 192.168.15.2 to 192.168.15 by using following sed command.

# sed -i -- 's/192.168.15.2/192.168.15.3/g' /etc/resolv.conf

Posted by chandu on December 12th 2017 08:53 AM

If you run the command to it will change to 192.168.15.3 After run the above command, then Check the name server ip address is changed or not by using following command.

#  cat /etc/resolv.conf
Answer Question

Your email address will not be published. Required fields are marked *

  • Minimum 20 character
AXF2

related questions

Most liked questions

Most answered questions

Login
AXF2 Refresh
Register
AXF2 Refresh
Forgot password
Ask a Question
Minimum 20 character
Minimum 20 character
Reply
Minimum 20 character
AXF2 Refresh