Bash to append domain in search field of resolv.conf after vpnc connection in Linux

After vpn connection,I am not able to resolve any machines in remote gateway.It looks like remote domain is added to domain field instead of adding it to the Search field in /etc/resolv.conf

I want the remote domain to add to search field along with local domain.Can anyone tell a bash or script to do it?

A few questions:-

  • What have you tried so far?
  • What errors/output/messages do you get?
  • What is your config file like at the time of the problem?
  • What OS and version are you using?

Most importantly, What have you tried so far?

It would be helpful if you could post a before and after view of /etc/resolv.conf in CODE tags too.

Robin

1 Like

Thank you rbattle1...
I have tried to edit the resolv.conf using vi editor But as I am student I dont know about the creation of script for this?
My Os is RHEL6
This is the resolv.conf which U will get clear idea
sorry for the delay

#Resolv.conf before vpnc start
--------------------------------------

[root@tstdpigw02 etc]# more resolv.conf
# Generated by NetworkManager
domain dev-dpi.india.blazer.com
search dev-dpi.india.blazer.com
nameserver 172.16.2.1
nameserver 172.16.2.3

[root@tstdpigw02 etc]# service vpnc start
Starting VPNC connection: VPNC started in background (pid: 2230)...

# Resolv.conf after vpnc start
--------------------------------

[root@tstdpigw02 etc]# more resolv.conf
#@VPNC_GENERATED@ -- this file is generated by vpnc
# and will be overwritten by vpnc
# as long as the above mark is intact
# Generated by NetworkManager
domain usdev.harley.com
search dev-dpi.india.blazer.com
nameserver 10.0.1.7

#Required resolv.conf after vpnc start
----------------------------------------

[root@tstdpigw02 etc]# more resolv.conf.required
#@VPNC_GENERATED@ -- this file is generated by vpnc
# and will be overwritten by vpnc
# as long as the above mark is intact
# Generated by NetworkManager
domain usdev.harley.com
search dev-dpi.india.blazer.com usdev.harley.com
nameserver 172.16.2.1

---------- Post updated 06-02-14 at 12:16 AM ---------- Previous update was 06-01-14 at 11:46 PM ----------

#Resolv.conf before vpnc start
--------------------------------------

[root@tstdpigw02 etc]# more resolv.conf
# Generated by NetworkManager
domain dev-dpi.india.blazer.com
search dev-dpi.india.blazer.com
nameserver 172.16.2.1
nameserver 172.16.2.3

[root@tstdpigw02 etc]# service vpnc start
Starting VPNC connection: VPNC started in background (pid: 2230)...

# Resolv.conf after vpnc start
--------------------------------

[root@tstdpigw02 etc]# more resolv.conf
#@VPNC_GENERATED@ -- this file is generated by vpnc
# and will be overwritten by vpnc
# as long as the above mark is intact
# Generated by NetworkManager
domain usdev.harley.com
search dev-dpi.india.blazer.com
nameserver 10.0.1.7

#Required resolv.conf after vpnc start
----------------------------------------

[root@tstdpigw02 etc]# more resolv.conf.required
#@VPNC_GENERATED@ -- this file is generated by vpnc
# and will be overwritten by vpnc
# as long as the above mark is intact
# Generated by NetworkManager
domain usdev.harley.com
search dev-dpi.india.blazer.com usdev.harley.com
nameserver 172.16.2.1