Thursday, September 6, 2012

VirtualBox CentOS 5.8 guest DHCP add search

I have a CentOS 5.8 guest using VirutalBox. There are two network interface, one is NAT, and the other is "Host Only". I have three environments
  1. In company, there are three networks, and;
  2. At home, I want to access the Internet without VPN;
  3. Use VPN at home to access company's networks.
Here is my issue: If check "Automatically obtain DNS information from provider" in network configuration, only in search of /etc/resolv.conf
; generated by /sbin/dhclient-script
nameserver xx.10.217.47

This is not convenient because I have to type the full DNS name if I want to access a host instead of hostA.

I can add the other twos in DNS tab network-configuration, but the change will be overwritten by dhclient when the interface is restarted, or machine reboot.

If set DNS name servers will be different for company and home. It works in one environment and fails in the others. Company internal DNS servers are accessible from outside without VPN.

Here is my solution to config dhclient to include the other two network in DNS search like this:

add /etc/dhclient-eth1.conf

interface "eth1" {
    append domain-name "";
Then restart the network:
sudo /sbin/service network restart
  • a blank in domain-name value is important because the string is simply concatenated to the string retrieved from the provider.
  • if it is not working, check /var/log/message
  • use "domain-name" for search. "domain-search" is not correct for CentOS 5.8.

No comments:

Post a Comment