Kea DHCPv6 CSV import – format?

Started by 9axqe, June 09, 2025, 09:50:45 PM

Previous topic - Next topic
I'm struggling a bit to figure out the format.

I have configured the following fields in the CSV: subnet,ipv6,hostname,description

But I keep getting these errors for every line:

!! Duplicate entry exists
!! A value is required.
!! Address not in specified subnet

There are zero DHCPv6 reservations in Kea at the moment, hence I can't see how anything could be duplicate.

Are the column headers maybe mandatory? If yes, if someone knows the exact syntax, I'd be grateful. I can't find the documentation for this CSV import format so far.

So far I could figure out:

* the first line must be headers, otherwise it thinks the file is empty.
* Subnet should definitely not be the first value, because the moment I add two lines, it complains about duplicate entries. And since only the subnet is the same between these two lines, that must be the reason.

I read the kea documentation as best as I could, I even searched for migration tools support DHCPv6 in hope of reverse engineering it, but so far no luck.

ChatGPT helped me in the following way:

### ✅ **Kea DHCPv6 CSV Import – Expected Format**

While ISC Kea's web UI supports CSV imports, **the format must align exactly** with what the backend expects. For **DHCPv6 reservations**, the expected fields usually include:

```
duid,ip-addresses,hostname,hw-address,subnet-id
```

However, **`hw-address` is usually not used for DHCPv6**, and **you should focus on `duid` instead**.

---

### ⚠️ Clarifying the fields you mentioned:

| Your Field    | Expected? | Comments                                                                                             |
| ------------- | --------- | ---------------------------------------------------------------------------------------------------- |
| `subnet`      | ❌         | Not recognized as a valid column name – should be `subnet-id` (an **integer** ID, not subnet string) |
| `ipv6`        | ❌         | Should be `ip-addresses` (and must be a list, i.e., `["2001:db8::100"]`)                             |
| `hostname`    | ✅         | Accepted                                                                                             |
| `description` | ❌         | Not supported in CSV import – ignored or causes error                                                |

---

### ✅ **Minimal working example (DHCPv6)**

Try a CSV file like this:

```csv
duid,ip-addresses,hostname,subnet-id
00:03:00:01:aa:bb:cc:dd:ee:ff,"[\"2001:db8::100\"]",example-host,1
```

* **`duid`**: The DUID of the client (use actual format matching your client config, e.g. `00:01:00:01:...`)
* **`ip-addresses`**: Must be a **JSON array as a string**, even for one IP.
* **`subnet-id`**: This must match the `id` field of your configured DHCPv6 subnet (not the subnet address).
* **Headers are required.**

---

### 🔍 How to find `subnet-id`

In your Kea DHCPv6 config (usually in `kea-dhcp6.conf`), each subnet has a field:

```json
"subnet6": [
  {
    "id": 1,
    "subnet": "2001:db8::/64",
    ...
  }
]
```

Use the number from `"id": ...` as `subnet-id` in your CSV.

---

### 🧪 Troubleshooting the errors

| Error                             | Likely Cause                                                                             |
| --------------------------------- | ---------------------------------------------------------------------------------------- |
| `Duplicate entry exists`          | Same `duid` or `ip-addresses` already in config (check even old config fragments)        |
| `A value is required`             | One of the required fields (`duid`, `ip-addresses`, `subnet-id`) is missing or malformed |
| `Address not in specified subnet` | IP address does not fall within the subnet tied to `subnet-id`                           |

---

### ✅ Recommendations

1. Start with **one simple reservation** and verify import.
2. Use a **minimal field set**: `duid`, `ip-addresses`, `hostname`, `subnet-id`.
3. Validate `duid` format and ensure `subnet-id` matches exactly what Kea expects.
4. Check the Kea logs (`/var/log/kea.log` or wherever your system logs them) for detailed import messages.

---
Supermicro M11SDV-4C-LN4F AMD EPYC 3151 4x 2.7GHz RAM 8GB DDR4-2666 SSD 250GB

Would entering one reservation through the GUI and then exporting it to CSV not be easier? Then it would be in the correct format to copy.