[Kea-users] Hi, I have this Kea static configuration: ``` { "Dhcp4": { "valid-lifetime": 4000, "renew-timer": 1000, "rebind-timer": 2000, "interfaces-config": { "interfaces": [ "enp0s8" ] }, "lease-database": { "type": "memfile", "name": "/var/kea/dhcp4.leases" }, "valid-lifetime": 4000, "subnet4": [ { "subnet": "192.168.0.0/24", "pools": [ { "pool": "192.168.0.10 - 192.168.0.20" } ], "reservations": [ { "hw-address": "08:00:27:8e:15:8a", "ip-address": "192.168.0.11" }, { "hw-address": "08:00:27:8e:15:8b", "ip-address": "192.168.0.12" } ] } ], "next-server": "192.168.0.254", "boot-file-name": "pxelinux.0" }, "Logging": { "loggers": [ { "name": "kea-dhcp4", "output_options": [ { "output": "stdout" } ], "severity": "INFO" } ] } } ``` It works perfectly. I would like to do the same thing with PostgreSQL backend. I have initialized my PostgreSQL database with: [dhcpdb_create.pgsql ](https://github.com/isc-projects/kea/blob/master/src/share/database/scripts/pgsql/dhcpdb_create.pgsql) I have this kea

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Kea-users] Hi, I have this Kea static configuration: ``` { "Dhcp4": { "valid-lifetime": 4000, "renew-timer": 1000, "rebind-timer": 2000, "interfaces-config": { "interfaces": [ "enp0s8" ] }, "lease-database": { "type": "memfile", "name": "/var/kea/dhcp4.leases" }, "valid-lifetime": 4000, "subnet4": [ { "subnet": "192.168.0.0/24", "pools": [ { "pool": "192.168.0.10 - 192.168.0.20" } ], "reservations": [ { "hw-address": "08:00:27:8e:15:8a", "ip-address": "192.168.0.11" }, { "hw-address": "08:00:27:8e:15:8b", "ip-address": "192.168.0.12" } ] } ], "next-server": "192.168.0.254", "boot-file-name": "pxelinux.0" }, "Logging": { "loggers": [ { "name": "kea-dhcp4", "output_options": [ { "output": "stdout" } ], "severity": "INFO" } ] } } ``` It works perfectly. I would like to do the same thing with PostgreSQL backend. I have initialized my PostgreSQL database with: [dhcpdb_create.pgsql ](https://github.com/isc-projects/kea/blob/master/src/share/database/scripts/pgsql/dhcpdb_create.pgsql) I have this kea

Stéphane Klein
Hi,

I have this Kea static configuration:

```
{
  "Dhcp4": {
    "valid-lifetime": 4000,
    "renew-timer": 1000,
    "rebind-timer": 2000,
    "interfaces-config": {
      "interfaces": [ "enp0s8" ]
    },
    "lease-database": {
      "type": "memfile",
      "name": "/var/kea/dhcp4.leases"
    },
    "valid-lifetime": 4000,
    "subnet4": [
      {
        "subnet": "192.168.0.0/24",
        "pools": [
          {
            "pool": "192.168.0.10 - 192.168.0.20"
          }
        ],
        "reservations": [
            {
                "hw-address": "08:00:27:8e:15:8a",
                "ip-address": "192.168.0.11"
            },
            {
                "hw-address": "08:00:27:8e:15:8b",
                "ip-address": "192.168.0.12"
            }
        ]
      }
    ],
    "next-server": "192.168.0.254",
    "boot-file-name": "pxelinux.0"
  },
  "Logging": {
    "loggers": [
      {
        "name": "kea-dhcp4",
        "output_options": [
          {
            "output": "stdout"
          }
        ],
        "severity": "INFO"
      }
    ]
  }
}
```

It works perfectly.

I would like to do the same thing with PostgreSQL backend.

I have initialized my PostgreSQL database with: [dhcpdb_create.pgsql
](https://github.com/isc-projects/kea/blob/master/src/share/database/scripts/pgsql/dhcpdb_create.pgsql)

I have this kea configuration file:

```
{
  "Dhcp4": {
    "valid-lifetime": 4000,
    "renew-timer": 1000,
    "rebind-timer": 2000,
    "interfaces-config": {
      "interfaces": [ "enp0s8" ]
    },
    "lease-database": {
      "type": "memfile",
      "name": "/var/kea/dhcp4.leases"
    },
    "valid-lifetime": 4000,
    "hosts-database": {
      "type": "postgresql",
      "name": "kea",
      "user": "kea",
      "password": "password",
      "host": "127.0.0.1"
    },
    "subnet4": [
      {
        "subnet": "192.168.0.0/24",
        "pools": [
          {
            "pool": "192.168.0.10 - 192.168.0.20"
          }
        ]
      }
    ],
    "next-server": "192.168.0.254",
    "boot-file-name": "pxelinux.0"
  },
  "Logging": {
    "loggers": [
      {
        "name": "kea-dhcp4",
        "output_options": [
          {
            "output": "stdout"
          }
        ],
        "severity": "INFO"
      }
    ]
  }
}
```

Next, for now I have inserted this data in database:

```
DELETE FROM lease4;
INSERT INTO lease4 (
  address,
  hwaddr,
  hostname
) VALUES(
  '192.168.0.11'::inet - '0.0.0.0'::inet,
  DECODE(REPLACE('08-00-27-8e-15-8a', '-', ''), 'hex'),
  'blank_machine'
);
INSERT INTO lease4 (
  address,
  hwaddr,
  hostname
) VALUES(
  '192.168.0.12'::inet - '0.0.0.0'::inet,
  DECODE(REPLACE('08-00-27-8e-15-8b', '-', ''), 'hex'),
  'test-dhcp-server'
);
```

but this insert are incomplete.

Do you have example how to insert properly my host in Kea PostgreSQL database?

Best regards,
Stéphane

--

_______________________________________________
Kea-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users