# FreeBSD as a DHCP server on a VLAN'ed network



## taliez (Mar 10, 2011)

Hi all.

I'm totally new to FreeBSD, I tried FreeBSD 8.0 (stable version). I want to try FreeBSD as a DHCP server on a VLAN'ed network. I don't have problems on the installation. 

I read somewhere that I have to confgure rc.conf for my network settings and resolv.conf for the DNS. Our network is behind a firewall and if I want unrestricted Internet connection I make the firewall as a gateway and set an ip to connect to the net.

I tried this in my rc.conf:


```
hostname=" server name"	
defaultrouter="gateway"
ifconfig_device="inet IP machine netmask 255.255.255.0"
```

and my resolv.conf


```
nslookup file bind
DNS Server = >public dns
```

This is what I do on windows boxes when I update them manually, but on FreeBSD, I'm unsuccessful. What did I miss?

Thank you in advance.


----------



## SirDice (Mar 10, 2011)

Start reading the handbook, pretty much all your questions are answered in there.

FreeBSD Handbook


----------



## taliez (Mar 10, 2011)

I will, sir. Thanks for the reply.


----------



## DutchDaemon (Mar 10, 2011)

And also please read your signup email. Your post is a mess, does not have a proper title and is in the wrong section.
http://forums.freebsd.org/showthread.php?t=11799


----------



## taliez (Mar 10, 2011)

Thank you MOD and sorry for the mess ..


----------



## taliez (Mar 23, 2011)

Hi, I've been reading some FreeBSD tutorials, almost all of them just use a single-subnet DHCP server as example. I would like to ask advice about using an alias or VLAN tagging.

Thanks in advance


----------



## SirDice (Mar 23, 2011)

If you have Cisco routers/switches set up an ip-helper and point it to your DHCP server.

http://www.ciscopress.com/articles/article.asp?p=330807&seqNum=9


----------



## taliez (Mar 23, 2011)

Yes, it is already set up in our switches (Cisco 500's and 2900's). Our current DHCP server is a Windows box serving around four VLANs on 100.x, 300.x and 200.x subnets. I just want to transfer the DHCP service to a FreeBSD box. I consider this as a challenge and I will do anything to run this FreeBSD box.


----------



## SirDice (Mar 23, 2011)

I'm guessing the DHCP server is in a seperate server VLAN? That's usually the case and you don't have to do anything. Just configure the correct IP address and subnet mask on the server and you're good to go, the ip-helpers will do the rest.

It's also possible the 'original' DHCP server is on all four VLANs (trunked connection). In that case just define the correct VLAN interfaces on the FreeBSD box.


----------



## taliez (Mar 23, 2011)

Will my dhcpd.conf look like this?


```
#-100 vlan
subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.2  192.168.210.254
  option routers 192.168.100.1;

#-200 vlan
subnet 192.168.200.0 netmask 255.255.255.0 {
  range 192.168.20.2  192.168.200.254;
  option routers 192.168.200.1;

#-300 vlan
subnet 192.168.300.0 netmask 255.255.255.0 {
  range 192.168.300.2  192.168.300.254;
  option routers 192.168.300.1;
```

And part of my rc.conf, like this?


```
cloned_interfaces="vlan100 vlan200 vlan300"
ifconfig_vlan100="inet 192.168.100.1  netmask 255.255.255.0 vlan 100 vlandev xx0"
ifconfig_vlan200="inet 192.168.200.1 netmask 255.255.255.0 vlan 200 vlandev xx0"
ifconfig_vlan300="inet 172.168.300.1 netmask 255.255.255.0 vlan 300 vlandev xx0"
```


----------



## taliez (Mar 23, 2011)

Is this okay?


```
ifconfig_vlan100="inet 192.168.100.1 netmask 255.255.255.0 vlan 100 vlandev xx0("
ifconfig_vlan200="inet 192.168.200.1 netmask 255.255.255.0 vlan 200 vlandev xx0"
ifconfig_vlan300="inet 192.168.300.1 netmask 255.255.255.0 vlan 300 vlandev xx0"
```



```
#-100 vlan
subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.2  192.168.200.254;
  option routers 192.168.100.1;

#-200 vlan
subnet 192.168.200.0 netmask 255.255.255.0 {
  range 192.168.200.2  192.168.200.254;
  option routers 192.168.200.1;

#-300 vlan
subnet 192.168.300.0 netmask 255.255.255.0 {
  range 192.168.300.2  192.168.300.254;
  option routers 192.168.300.1;
```


----------



## SirDice (Mar 23, 2011)

Check the range on the 100 and 200 VLANs, they contain a small error. Besides that, it looks good.


----------



## taliez (Mar 23, 2011)

BTW Sir, is this necesarry ?


```
ifconfig_xx0="up"
```


```
#-100 vlan
subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.2  192.168.100.254
  option routers 192.168.100.1;

#-200 vlan
subnet 192.168.200.0 netmask 255.255.255.0 {
  range 192.168.200.2  192.168.200.254;
  option routers 192.168.200.1;

#-300 vlan
subnet 192.168.300.0 netmask 255.255.255.0 {
  range 192.168.300.2  192.168.300.254;
  option routers 192.168.300.1;
```


----------



## SirDice (Mar 23, 2011)

taliez said:
			
		

> btw sir is this necesarry ?
> 
> 
> ```
> ...


Yes, otherwise the interface itself will be down even though you defined the vlan interfaces.


----------



## taliez (Mar 23, 2011)

Thanks very much sir, I'll update this as soon as I test it with my test VLAN.


----------



## taliez (Mar 24, 2011)

Just a quick question. What if for example the IP address of my FreeBSD server is 192.168.90.90 and my dhcp ranges are 100.x, 200.x and 300.x.

Is this possible?

Thanks.


----------



## SirDice (Mar 24, 2011)

Yes, that possible. You will need to use the ip-helper though.


----------



## taliez (Mar 24, 2011)

Okay, so I guess 192.168.90.90 will not be pingable in the 90.x network which the servers vlan. Because I tried it now, it's not pingable and manageable. In ssh I can manage it by physical terminal only.

How can this broadcast IP addresses in the network/vlan assuming the ip-helper this is in place in the cisco switches?


----------



## SirDice (Mar 24, 2011)

It sounds like you need to take a long hard look at your routing. There's no reason why the machine shouldn't be ping'able. But that all depends on how your network is configured.

The ip-helper on the Cisco routers will "translate" a client's broadcast DHCP REQUEST into a unicast address. As long as your routing is working correctly your server will receive the request and reply correctly.


----------

