HenriWahl / dhcpy6d

MAC address aware DHCPv6 server written in Python
https://dhcpy6d.de
GNU General Public License v2.0
97 stars 27 forks source link

Fixed IPv6 address only? #10

Closed richarson closed 7 years ago

richarson commented 7 years ago

Hello, I'm testing dhcpy6d and so far I'm liking it.

One issue I found is that it gives my test client 2 IPv6 addresses: the one I set in dhcpy6d-clients.conf and another generated with the client's MAC address.

My dhcpy6d.conf is:

[dhcpy6d]
interface = wan0
serverduid = xxxxxxxxxxxxxxxxxxxxx
user = dhcpy6d
group = dhcpy6d
nameserver = 2800:PP::NNNN 2800:PP::NNNN
domain = domain.tld
domain_search_list = domain1.tld domain2.tld
log = on
log_file = /var/log/dhcpy6d.log
store_config = file
store_volatile = sqlite
store_sqlite_volatile = /var/lib/dhcpy6d/volatile.sqlite
store_file_config = /etc/dhcpy6d-clients.conf
really_do_it = yes
identification = mac duid
identification_mode = match_some
dns_update = no

[address_default]
category = mac
pattern = fd01:db8:dead:bad:beef:$mac$

[address_openstack]
category = mac
pattern = 2800:PP::$mac$

[class_default]
answer = none

[class_openstack]
addresses = openstack

And my dhcpy6d-clients.conf:

[host01]
hostname = host01.domain.tld
mac = XX:XX:XX:XX:XX:XX
class = openstack
address = 2800:PP::NNNN

I use answer = none in [class_default] to prevent unknown clientes from getting an IP from me :)

I tried commenting out category and pattern in [address_default] and [address_openstack] but now I get an IPv6 from 2001:db8::/64 instead of the MAC address-based one, in adition to my fixed IPv6 in dhcpy6d-clients.conf.

Is there a way to get only the fixed IPv6 from dhcpy6d-clients.conf?

HenriWahl commented 7 years ago

Hi, the address option in client definition is really meant to be an extra address. If you want just one short fixed address you should set the category of address_openstack to "id" and give one id in the client definition, like

[address_openstack]
category = id
pattern = 2800:PP::$id$

and

[host01]
hostname = host01.domain.tld
mac = XX:XX:XX:XX:XX:XX
class = openstack
id = 1
richarson commented 7 years ago

OK, I'll try that tomorrow.

Thanks!

richarson commented 7 years ago

It didn't work for what I'm trying to do, but I'll keep it in mind if we change our requirements.

For now, I'll have to live with 2 IPv6 addresses :)

HenriWahl commented 7 years ago

What exactly do you want to reach? What is the result you get now?

richarson commented 7 years ago

I want to give a specific IPv6 based on the IPv4 like so:

IPv4: 123.45.67.89
IPv6: 2800::PP:123:45:67:89

It's just to make it easier to relate and remember, and it's not (AFAIK) a standard method.

Now I get that specific IPv6 from dhcpy6d-clients.conf + another IPv6 autogenerated either with the MAC address or ID, whichever I configure in dhcpy6d.conf.

So I guess what I'd need is to be able to omit category and pattern from dhcpy6d.conf and use only what's in dhcpy6d-clients.conf (or a database, which is what I'm actually using).

So, dhcpy6 works as intended, it's just a specific requirement I have.

I'll probably just stick to category = id and use 123:45:67:89 as ID.

Which, now that I think about it some more (and after some more testing), is problably what you intended for me to do in the first place :)

HenriWahl commented 7 years ago

The IDs are intended to consist of any number between 0000 and FFFF. But in the current development version I started to implement the possibility to only use the dchpy6d-client.conf addresses so expect this to work in the future.

HenriWahl commented 7 years ago

You might get help already with the current version - just leave your class definition WITHOUT the "addresses" line. Then no addresses are defined and only the fixed ones will be used.

richarson commented 7 years ago

Well, I already moved to kea for dhcpv6 :( Actually, I'm already using kea for dhcpv4 but since I couldn't make v6 work I started looking for alternatives and dhcpy6d seemed very nice and straighforward.

That said, I'll see if I can give it a try, at the very least to confirm it works, give you feedback and have it as a backup plan.

Thanks for your work!