# Requesting Specific Address From DHCP



## billli (Nov 22, 2011)

Hi:
Suppose if I have a DHCP server with a pool of address from 192.168.0.1-192.168.0.100

And for interface em0 I want to request the address of 192.168.0.50, is this possible with FreeBSD?

I know I can do:

```
interface "em0" {
   send host-name "myhostname";
   send dhcp-requested-address 192.168.0.50;
}
```

in dhclient.conf on other OS, is there a similar command like this for FreeBSD?

Or do I simply just do:

```
ifconfig em0 192.168.0.50
```
?

Thanks
Bill


----------



## wblock@ (Nov 22, 2011)

I suspect the first will work but haven't tried it.

As long as an address isn't already in use, the second will work.  DHCP servers ping an address before assigning it, so it will reassign that address.


----------



## SirDice (Nov 23, 2011)

You could also reserve that IP address on the DHCP server. You can couple the machine's MAC address to a specific IP address so that machine will always receive the same IP address.


----------



## fluca1978 (Nov 23, 2011)

SirDice said:
			
		

> You could also reserve that IP address on the DHCP server. You can couple the machine's MAC address to a specific IP address so that machine will always receive the same IP address.



This is the right way of doing. I don't see the point in requesting a preferred IP to a dhcp server, since DHCP is made to let clients don't bother with IPs....


----------



## wblock@ (Nov 23, 2011)

There are use cases, like a broadband client without any control over the ISP attempting to keep the dynamic IP address they've been using.


----------



## fluca1978 (Nov 24, 2011)

wblock@ said:
			
		

> There are use cases, like a broadband client without any control over the ISP attempting to keep the dynamic IP address they've been using.



Correct. However you cannot rely on it.


----------

