Infoblox plugin DHCP IP suggestion system throwing 400 errors

Hi folk,

I’m having an issue with Foreman’s Infoblox plugin (I think…)

I installed infoblox dns and dhcp plugins successfully, and configured them with appropriate login information and all.

Access to foreman-proxy via ssl is disabled, http only.

When creating a new host in Foreman, I’ll go to the interface section and edit the interface, put in a MAC address and choose subnet/etc, then I try to click “Suggest an IP” and get this red error:

Failed to fetch a free IP from proxy foreman-proxy (http://foreman-proxy:8443): ERF12-8202 [ProxyAPI::ProxyException]: Unable to retrieve unused IP ([RestClient::BadRequest]: 400 Bad Request) for proxy http://foreman-proxy:8443/dhcp

Additionally, a red error under “IPv6 address”:

Error generating IP: Bad Request

Looking at the logs on foreman-proxy, I see the following when I try using a MAC address for the interface:

E, [2018-01-31T12:20:44.712013 #19377] ERROR -- : 757: unexpected token at '<HTML><HEAD><META HTTP-EQUIV="REFRESH" CONTENT = "0; URL=https://10.x.x.75"/></HEAD><BODY BGCOLOR="FFFFFF">Click <A HREF="https://10.x.x.75">here</A> if page does not refresh in 10 seconds.</BODY></HTML>
'
I, [2018-01-31T12:20:44.712657 #19377]  INFO -- : 10.x.x.19 - - [31/Jan/2018:12:20:44 +0000] "GET /dhcp/10.x.x.0/unused_ip?mac=XX:XX:XX:XX:XX:XX HTTP/1.1" 400 233 0.3222

I get the following without a MAC address entered:

E, [2018-01-31T12:24:01.292105 #19377] ERROR -- : 757: unexpected token at '<HTML><HEAD><META HTTP-EQUIV="REFRESH" CONTENT = "0; URL=https://10.x.x.75"/></HEAD><BODY BGCOLOR="FFFFFF">Click <A HREF="https://10.x.x.75">here</A> if page does not refresh in 10 seconds.</BODY></HTML>
'
I, [2018-01-31T12:24:01.292533 #19377]  INFO -- : 10.x.x.19 - - [31/Jan/2018:12:24:01 +0000] "GET /dhcp/10.x.x.0/unused_ip HTTP/1.1" 400 233 0.2524

I try to just use curl from the foreman front host, and it seems to work fine getting an IP address, no 400 errors or anything:

# curl http://foreman-proxy:8443/dhcp/10.x.x.0/unused_ip?mac=XX:XX:XX:XX:XX:XX | jq . 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    19  100    19    0     0     52      0 --:--:-- --:--:-- --:--:--    52
{
  "ip": "10.x.x.27"
}

I’m just looking for a lead, at least, as to where to look to figure this out.

Any help is greatly appreciated, we want to get this up and running soon to get a pile of important virtual machines migrated using foreman for deploying.

Cheers,
Shawn Q.

It’d be helpful to know which versions you are using (foreman, proxy, infoblox plugin, infoblox itself).

Of course, my apologies:

Foreman front server is 1.15.3 Release: 1.el7
foreman-proxy 1.13.4 Release: 1.el7
rubygem-infoblox 1.0.0 Release: 1.el7
rubygem-smart_proxy_dhcp_infoblox 0.0.5 Release: 1.fm1_14.el7
rubygem-smart_proxy_dns_infoblox 0.0.4 Release: 1.fm1_13.el7
Infoblox NIOS Release 8.1.5-359439 (64bit)

I’d consider upgrading the proxy to at least 1.15 since that’s supported. That should have an updated version (0.0.7) which might fix it.

Thanks for the suggestion

Upgraded, foreman-proxy Version: 1.15.6 Release: 1.el7

Restarted foreman-proxy, logged out/back in, created host, but looks like I still get the same error in interface section “Suggest an IP”:

Failed to fetch a free IP from proxy foreman-proxy (http://foreman-proxy:8443): ERF12-8202 [ProxyAPI::ProxyException]: Unable to retrieve unused IP ([RestClient::BadRequest]: 400 Bad Request) for proxy http://foreman-proxy:8443/dhcp

Log on proxy now shows:

E, [2018-01-31T17:07:03.164062 ] ERROR -- : 757: unexpected token at '<HTML><HEAD><META HTTP-EQUIV="REFRESH" CONTENT = "0; URL=https://10.x.x.75"/></HEAD><BODY BGCOLOR="FFFFFF">Click <A HREF="https://10.x.x.75">here</A> if page does not refresh in 10 seconds.</BODY></HTML>
'
I, [2018-01-31T17:07:03.164491 ]  INFO -- : 10.x.x.19 - - [31/Jan/2018:17:07:03 +0000] "GET /dhcp/10.x.x.0/unused_ip?mac=54:52:00:f0:51:37 HTTP/1.1" 400 233 0.3188

curl still works fine from foreman front:

# curl http://foreman-proxy:8443/dhcp/10.x.x.0/unused_ip | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    19  100    19    0     0      6      0  0:00:03  0:00:02  0:00:01     6
{
  "ip": "10.x.x.27"
}

Where else might I sniff around to figure this out?

Also, this error is the content returned when you haven’t successfully authenticated against the infoblox. You should try testing your credentials using curl and see if you can use the REST API Guide to make sure you can create a DHCP reservation manually. If you can’t do it with curl, the smart proxy won’t be able to do it either.

Forgive me, I’m still new to both systems.

So I took the same user / password that’s in the dhcp infoblox yaml, and it turned out the server we were trying to use was invalid - so that was it!

Thanks for the tip, it helped solve the problem.

For anyone else looking to test authentication against Infoblox API:

First:

$ curl -k -u 'admin:infoblox' -X GET "https://infoblox/wapi/v2.6/network?network~=10.x.x&_return_as_object=1"
{
    "result": [
        {
            "_ref": "network/gobbledygook:10.x.x.0/23/default", 
            "comment": "KNET :: stuff", 
            "network": "10.x.x.0/23", 
            "network_view": "default"
        }
    ]
}

Second, take gobbledygook and put in here:

$ curl -k -u 'admin:infoblox' -H 'content-type: application/json' -X POST "https://infoblox/wapi/v2.6/network/gobbledygook:10.x.x.0/23/dfault?_function=next_available_ip&_return_as_object=1" -d '{"num":1}'
{
    "result": {
        "ips": [
            "10.x.x.3"
        ]
    }
}
1 Like