Link to home
Start Free TrialLog in
Avatar of Peter Martin
Peter Martin

asked on

Script to Change DNS on Linux servers to include new FQDN in all files

This is what I want to do, I have a script to check and add the new search DNS domain in /etc/resolv.conf, however I am trying to develop the script to do all of the below:

Check hostname, if using FQDN change to correct DNS name
check /etc/resolv.conf and remove old DNS search and nameservers, then put new nameservers in file.
check /etc/hosts, and remove old DNS domain name and put in new DNS domain name to server name.
check /etc/sysconfig/network, put full server name with new DNS appended to server short name.
check /etc/sysconfig/network-scripts/ifcfg-eth#, remove old DNS statements and put new in file.
service network restart

Thanks,
Peter
ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Martin
Peter Martin

ASKER

David,

Thanks for your reply, and yes I see that the Network Interface setup on most servers has DNS nameservers, ect.  I was thinking about why this would be the case, but now understand this would be the way to go.  

Best Regards,
Peter Martin