# DNS multiple domains



## jtorres10 (Nov 30, 2013)

Hey there, I'm new to the FreeBSD world and I'm trying to do a small network with DNS, HCP, HTTP, iptables and Squid. For now I'm starting with DNS. I managed to get DNS working, forward and inverse zones. I have a doubt here if I have multiple domains like: xxxxx.com, xxxxxx.org, xxxxxxx.biz, etc., do I need to do a forward zone for each? A new database file for each? To then link to the named.conf file I'm assuming. Can anyone explain it to me? Thank you.


----------



## johnblue (Dec 1, 2013)

Correct.  Each zone will have a new master database file.


----------



## jtorres10 (Dec 1, 2013)

Thank you for your reply. I have created all master db files. How about the resolv.conf file? What do I edit there? Which domain and nameserver? That's my doubt on finally understanding DNS on free BSD FreeBSD.


----------



## ShelLuser (Dec 1, 2013)

When in doubt always read the resolv.conf(5) manual page. It will explain the syntax and which keywords you can use. Basically it doesn't differ that much from Linux. And on that subject:



			
				jtorres10 said:
			
		

> Hey there, I'm new to the FreeBSD world and I'm trying to do a small network with DNS, HCP, HTTP, iptables and Squid.


Be aware that utilities such as HCP and IPTables are specific Linux tools and therefore won't work on FreeBSD.

When it comes to firewalls you have three options to chose from: IPFilter, IPFirewall and PF. You can read more about those in chapter 29 of the FreeBSD handbook (the handbook is really a must-read if you're going to experiment with FreeBSD).

HTTP, Squid and DNS can all be handled of course. Bind is provided by the base system, for the rest of the software you need to turn to the ports collection. You'll probably be looking out for software such as www/apache22 and www/squid. Note that the BIND version which is supplied by the base system isn't the "latest and greatest". If you need a modern version of BIND (or another DNS server of course) you should also turn to the ports collection. For example, you can find BIND 9.9.4 as dns/bind99.

If you need more information on using the ports collection then check out chapter 5 of the FreeBSD handbook, this explains how you can install software on FreeBSD. You will especially want to check out section 5.6 which explains the ports collection in more detail.

Edit: _fixed tags_


----------



## kpa (Dec 1, 2013)

The resolv.conf(5) is only for configuring the so called local resolver, it has no effect on how BIND itself operates. Most often you can use 127.0.0.1 as the nameserver on the host that runs the DNS server because the nameserver is listening for connections on the localhost address 127.0.0.1.


```
search mymaindomain.tld otherdomain.tld
nameserver 127.0.0.1
```

The search lines sets the search path for simple unqualified host names. For example myhost would be tried as myhost, myhost.mymaindomain.tld and myhost.otherdomain.tld.

On any other host you'll have to use the LAN address of the DNS server in resolv.conf(5).


----------



## SirDice (Dec 1, 2013)

jtorres10 said:
			
		

> I managed to get DNS working, forward and inverse zones. I have a doubt here if I have multiple domains like: xxxxx.com, xxxxxx.org, xxxxxxx.biz, etc., do I need to do a forward zone for each? A new database file for each?


Yes, and you need a reverse too, unless it all resolves to the same IP addresses. 



> To then link to the named.conf file I'm assuming. Can anyone explain it to me? Thank you.


Yes, you simply create more zones, if you can create one zone you can make two, three or even more in exactly the same way. Just point them to different zone files.


```
zone "dicelan.home." {
                type master;
                notify no;
                file "/etc/namedb/dynamic/dicelan.home";
                allow-update { 127.0.0.1; key DHCP; };
        };
        zone "dicelan.org." {
                type master;
                notify no;
                file "/etc/namedb/dynamic/dicelan.org";
                allow-update { 127.0.0.1; key DHCP; };
        };
```


----------



## jtorres10 (Dec 1, 2013)

Thank you all for your replies. They have been helpful. I started checking out the manual, very helpful as well. I managed to get all the DNS services running but now I find myself with a new problem and I don't see it in the manual. Now I'm trying to install DHCP but i don't get anywhere due to the fact that when I do:
`#cd /usr/ports/net/isc-dhcp42-server`
`#make install clean`
It shows many lines that begin with [i["attempting to fetch ftp:..."[/i], to the end when it stops it shows:

```
*** [do-fetch] Error code 1
Stop in /usr/ports/net/isc-dhcp42-server.
*** [install] Error code 1.
```
I'm not really sure how to go about resolving this. This is the first time I've encountered such a problem. Any suggestions? Thank you.


----------



## trh411 (Dec 1, 2013)

That typically indicates the necessary distribution file cannot be downloaded from any of the possible source sites. It has happened to me on a few occasions. Wait for a while and try again.


----------



## jtorres10 (Dec 3, 2013)

Thank you, I managed to fix the error. It was in the resolv.conf file. Now that I managed to install DHCP i have been reading the manual on DHCP for multiple domains and VLANS but I don't seem to see any of that there. I think that I must configure dhcp.conf for each domain. Also I see that to configure DHCP I need the client's MAC address but what if I don't know the addresses? Any suggestions?


----------



## kpa (Dec 3, 2013)

You don't really configure DHCP for DNS domains but for network interfaces and subnets. By default the dhcpd(8) listens on all network interfaces and that can be changed if needed with the dhcpd_ifaces setting in /etc/rc.conf. For example I have this setting with my LAN interface being rl0:


```
dhcpd_ifaces="rl0"
```

In dhcpd.conf(5) you then list all the subnets that you want to hand out IP addresses from. Let's say you have one real interface em0 with IP address 192.168.0.1 and a VLAN named vlan1 on some other interface with IP address 172.16.0.1. You would then list the address ranges like this:


```
subnet 192.168.0.0 netmask 255.255.255.0 {
    option routers 192.168.0.1;
    range 192.168.0.100 192.168.0.199;
}

subnet 172.16.0.0 netmask 255.255.255.0 {
    option routers 172.16.0.1;
    range 172.16.0.100 172.16.0.199;
}
```

I made up the ranges to be from .100 to .199 in this example, they can be set just as you like.

That's the basic idea. Note that you don't and can't mention the interface names in the config file, the dhcpd(8) daemon matches the IP address of the interface the request comes in to the list of subnets in the config file and determines the right subnet from that.


----------



## jtorres10 (Dec 6, 2013)

Thank you, I managed to fix the VLAN problem. Now I decided to experiment with Apache22 and it works. I have tried to install Joomla and I managed to open it in my browser but when I'm in the last step where I must delete the installation directory and I try to continue with the installation, the page just fails to load. It marks page not found. What must be causing this? I have tried reinstalling but when i open my Joomla in the browser it jumps directly to last step causing me not able to configure the first steps of Joomla anymore. Any suggestions on how to get this fixed?


----------

