I have a FreeBSD machine with two NICs set up as follows:
em0 ---> IP set via DHCP (192.168.1.0/24). "home" domain
em1 ---> IP set statically (10.0.0.2). "lab" domain
For all intents and purposes, my home domain works fine. I can get to the internet and ping any host on the network. Routing also works, I can ping any host from either domain from the FreeBSD machine via IP but, I can only resolve names on the home network.
I created a /etc/resolvconf.conf
file to prepend the search domain and name server to the resolv.conf
file as follows:
search_domains="lab"
name_servers="10.0.0.10"
I then update resolv.conf with the command:
$ sudo resolvconf -u
I can now resolve names on the lab
network, but no longer on the home
network. Manually editing the resolv.conf file and reversing the order of domains and name servers results in resolving home
but not lab
- exactly opposite.
How can I tell resolv.conf
to use one DNS server for a particular domain (the statically set IP) and allow it to get the DNS info for the other IP via DHCP?
Just for reference....
/etc/rc.conf:
hostname="beastie1"
ifconfig_em0="DHCP"
ifconfig_em1="inet 10.0.0.2 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
/etc/resolv.conf
# Generated by resolvconf
search lab home.
nameserver 10.0.0.10
nameserver 192.168.1.1
The DNS "server" on the lab
domain 10.0.0.0 is nothing more than a cheap consumer Netgear router that does provide DHCP leases. I only have this set statically because it's a TFTP server for bootimages and I purposely set it to 10.0.0.2 for ease of use when trying to flash firmware updates on some Cisco gear.
/etc/hosts
on the FreeBSD machine to resolve lab addresses, leaving DNS pointing to home only. This would only work for address resolution on the FreeBSD machine itself. Alternatively, run a DNS server on the FreeBSD machine. There are a number of ways to configure it such that unresolved domains are forwarded to the home DNS./etc/hosts
and solve the issue, but the reason for my approach/question is more academic in nature. I wanted to know if I was in a large network with a sizeable lab how I would accomplish this without having to modify/etc/hosts
on every workstation in the lab.