# DHCP on interface aliases?



## dvdmandt (Sep 29, 2010)

Is it possible to create an alias interface and use DHCP to request an IP address for it?

I tried this in rc.conf:


```
ifconfig_rl0="DHCP"
ifconfig_rl0_alias0="DHCP"
```
But that didn't work. Is what I'm trying to do possible, and if so, how can I do it?

What I want is just two ip-addresses for my server which only has one NIC. Is there any other way to achieve this?

Thanks


----------



## Savagedlight (Sep 29, 2010)

iirc, DHCP assigns IP addresses based on MAC address and/or hostname.
Check if it's possible to alter the reported MAC address on the alias?


----------



## dvdmandt (Sep 29, 2010)

I think the problem is that it doesn't really create a new interface, it just assigns a new IP to the existing interface. I could be wrong here. It has to be possible though, Vmware can do it.

I've managed to create an alias, but I can't do things like 
`dhclient rl0_alias0`
because it can't find rl0_alias0.


----------



## gordon@ (Oct 11, 2010)

You can't really request multiple DHCP leases for a single MAC address. I suppose you could create a virtual interface (check the epair(4) manual page), bridge(4) one half of the virtual to your LAN interface, and then run dhclient on the second half. It will cause problems with your routing table though if you have 2 interfaces on the same subnet.

What is it you are trying to do anyway?


----------



## mix_room (Oct 11, 2010)

Can you not assign the IPs manually?


----------



## dvdmandt (Oct 12, 2010)

I cannot assign them manually since I'm trying to request them from my ISP. I can get up to 5 public IPs from my isp.

There are multiple reasons, one being that I wanted to try to create my own implementation of something similar to mobile-ip. It's nothing important, just seemed like something interesting to experiment with.

If I get the time again, I'll try the epair+if_bridge thing. Thanks for your help!


----------



## phoenix (Oct 12, 2010)

Alternatively, just install multiple NICs into the system and call dhclient on each NIC.

You'll have to edit the dhclient.conf, though, to configure things so that only 1 DHCP request sets the default gateway.  Otherwise, it'll be the last dhclient to run that sets it.


----------

