scsitteam / netbox-windhcp

Webhook Server which syncs the Windows DHCP from Netbox
Apache License 2.0
11 stars 0 forks source link

DHCP Start Address is 0.0.0.0 #5

Open lewis-green opened 1 year ago

lewis-green commented 1 year ago

Having tried the tool I have worked through and added all the tags, roles etc. I have now got it to attempt to sync a prefix into DHCP.

When it does it sets the start address as 0.0.0.0.

Logs

2023-03-27 09:35:00 INFO netbox_windhcp::sync - Start sync from http://netbox/api/ to localhost
2023-03-27 09:35:00 INFO netbox_windhcp::sync - Found 1 Prefixes and 1 Ranges
2023-03-27 09:35:00 INFO netbox_windhcp::sync - Sync Prefix 10.25.200.0/24 - TEMP_LAN
2023-03-27 09:35:00 INFO netbox_windhcp::sync::windhcp::subnet - Set range to 0.0.0.0 - 10.25.200.254
2023-03-27 09:35:00 ERROR netbox_windhcp_sync - Error setting subnet range to : The parameter is incorrect.

PREFIX

{
    "id": 17,
    "url": "http://netbox/api/ipam/prefixes/17/",
    "display": "10.25.200.0/24",
    "family": {
        "value": 4,
        "label": "IPv4"
    },
    "prefix": "10.25.200.0/24",
    "site": {
        "id": 1,
        "url": "http://netbox/api/dcim/sites/1/",
        "display": "Test",
        "name": "Test",
        "slug": "Test"
    },
    "vrf": null,
    "tenant": null,
    "vlan": null,
    "status": {
        "value": "active",
        "label": "Active"
    },
    "role": null,
    "is_pool": false,
    "mark_utilized": false,
    "description": "",
    "comments": "",
    "tags": [
        {
            "id": 1,
            "url": "http://netbox/api/extras/tags/1/",
            "display": "dhcp",
            "name": "dhcp",
            "slug": "dhcp",
            "color": "9e9e9e"
        }
    ],
    "custom_fields": {},
    "created": "2023-03-24T12:53:32.895043Z",
    "last_updated": "2023-03-27T08:50:18.852579Z",
    "children": 0,
    "_depth": 2
}

IP RANGE

{
    "id": 5,
    "url": "http://netbox/api/ipam/ip-ranges/5/",
    "display": "10.25.200.10-254/24",
    "family": {
        "value": 4,
        "label": "IPv4"
    },
    "start_address": "10.25.200.10/24",
    "end_address": "10.25.200.254/24",
    "size": 245,
    "vrf": null,
    "tenant": null,
    "status": {
        "value": "active",
        "label": "Active"
    },
    "role": {
        "id": 1,
        "url": "http://netbox/api/ipam/roles/1/",
        "display": "dhcp-pool",
        "name": "dhcp-pool",
        "slug": "dhcp-pool"
    },
    "description": "",
    "comments": "",
    "tags": [],
    "custom_fields": {},
    "created": "2023-03-27T08:54:11.520715Z",
    "last_updated": "2023-03-27T08:59:42.168995Z"
}
jiuka commented 1 year ago

Hi @lewis-green

Are you able to share the current set range on the DHCP server with me? For example the output of the following command?

Get-DhcpServerv4Scope -ScopeId 10.25.200.0

Regards Marius

lewis-green commented 1 year ago

@jiuka There is no scope. Does it not create them if missing?

jiuka commented 1 year ago

@lewis-green it is created and then the range is set. So it should be there now, but with no or a wrong range. 0.0.0.0 as a start address. The setting of the range is a bit tricky as it is not possible to move a range only shrink or expand one. In this case my suspicion is that the 0.0.0.0 is returned from the DHCP Server as the start of the current range. Is there realy no Scope or just no range? Which version of Windows DHCP server are you using?

Regards marius

lewis-green commented 1 year ago

I've got this:

ScopeId          : 10.25.200.0
Name             : <omitted>
Description      : <omitted>
SuperscopeName   :
SubnetMask       : 255.255.255.0
StartRange       : 0.0.0.0
EndRange         : 0.0.0.0
LeaseDuration    : 00:00:00
NapProfile       :
NapEnable        : False
Delay(ms)        : 0
State            : Active
Type             : Dhcp
MaxBootpClients  : 4294967295
ActivatePolicies : True

It's Server 2022 DHCP.

lewis-green commented 1 year ago

It seems running it in VS Code with the source code it works fine but the 0.9.4 Installer doesn't work right.

jiuka commented 1 year ago

I added additional logic to limit the range to the scope 561541432a2fa0299f4ebbb778f967d2ba159bc8. However there seems to be some (maybe caching) problems if the installer does not work but the compiled version does. Still investigating this.

lewis-green commented 1 year ago

@jiuka It seems it all worked straight away with this 0.97 build :)