mpope
05-13-2002, 04:11 AM
I need to search through my named.conf file and replace all of the instances of ns1.mydomain.com with the IP for that nameserver. Now, I already did this once manually, but it got overwritten by cpanel when it updated (DOH!). Anyways, I am sure there is a way to do this in one clean sweep via the command line, so if someone could give me a quick and easy solution for this I would appreciate it!
Starhost
05-13-2002, 04:35 AM
Open your named.conf with vi.
Then type:
$s/nameserver_old/nameserver_new/gc
Now vi will replace nameserver_old with nameserver_new it will ask for permission everytime it sees nameserver_old. When you would like to change all nameserver_old in once, without vi asking permission everytime it finds nameserver_old.
leave away the c at behind of the command.
(SH)Saeed
05-13-2002, 04:43 AM
mpope, do chattr +i named.conf to make the file read-only. We added open_basedir line to our /scripts/wwwacct and CPanel kept overwriting the file and removing our added lines until we made it read-only.
RutRow
05-13-2002, 09:05 AM
You can also do:
sed s/ns1.mydomain.com/new_ip/g < named.conf > named.conf.new
Then if you are happy with the new file, copy it over the old.