Operating System - HP-UX
1754402 Members
3639 Online
108813 Solutions
New Discussion

adding a domain in /etc/resolv.conf

 
laiju.c.babu
Regular Advisor

adding a domain in /etc/resolv.conf

Hi Gurus,

 

I required to add one domain to /etc/resolv.conf file in more that 50 servers. Remsh is already available from one of the server to all those 50 servers.

 

Hence  could you please help me how can i add one domain entry in /etc/resolv.conf file using one for loop.

 

Regards

 

Laiju.C.Babu
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: adding a domain in /etc/resolv.conf

What is the current content of resolv.conf what do you need to do, add a line to the end?

domain new-domain

laiju.c.babu
Regular Advisor

Re: adding a domain in /etc/resolv.conf

Hi Dennis,

 

For example

 

Current content of /etc/reolv.conf is

 

cat /etc/resolv.conf

 

domain aaa.com
nameserver  **********
nameserver **********
search   bcd.net

 

I want to add one more domain for searching for example xyz.net

 

That means after the modification /etc/resolv.conf will look like below

 

cat /etc/resolv.conf

 

domain aaa.com

nameserver  **********

nameserver **********

search   bcd.net  xyz.net

 

I have to add this xyz.net entry to /etc/resolv.conf file in more that 50 servers.

In our scenarion remsh is enabled to all these 50 servers. 

Regards

Laiju.C.Babu
Dennis Handly
Acclaimed Contributor

Re: adding a domain in /etc/resolv.conf

>to: search   bcd.net  xyz.net

 

Perhaps something like:

#!/usr/bin/ksh
# Changes search line in /etc/resolv.conf


for mach in $(< list-of-servers); do
   echo "Doing: $mach ================"
   remsh $mach "ex /etc/resolv.conf <<EOF

%s/search   bcd.net/search   bcd.net  xyz.net/
wq /etc/resolv.conf.new
EOF
"
done

If you are happy with the results of /etc/resolv.conf.new, you can leave that name out and it will write back to the original file.

laiju.c.babu
Regular Advisor

Re: adding a domain in /etc/resolv.conf

Hi Dennis,

 

In  the servers we have different entries  in /etc/resolv.conf.

 

for eg : some servers we have 

 

search abc.net def.net   and in some others we have search abc.net xyz.net  etc.

 

In this scenario can we use the script which you mentioned below.

 

Regards

Laiju.C.Babu
Dennis Handly
Acclaimed Contributor

Re: adding a domain in /etc/resolv.conf

>search abc.net def.net   and in some others we have search abc.net xyz.net  etc.

 

I assume in the latter case you don't need to make the change?

If you need to customize the editing, then it is better to make a script and send it to each machine, unless you have a common NFS mounted directory you can use.