I am seriously lost and need help. DHCP issues

Hello! At my place of work, we’re testing out foreman and we’ve ran into a bit of an issue.

Problem:

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

Expected outcome:

We’re trying to get Foreman to manage DHCP with server boxes attached to it. Manage DNS, and be able to install OS’ using BMC. We’re running all of this on Rocky 8.

Foreman and Proxy versions:

Foreman and Proxy plugin versions:

Distribution and version:

At the time of writing this forum question, I sadly don’t have my work computer that’s connected to Foreman on me, but I have been following the guide that talks about installing and running version 3.4 Manual.

Other relevant data:

Sadly, unable to provide those logs, but I hope someone can try to give me something to go on to get this stupid issue solved.

Sorry, no idea without the logs, but have a look at the proxy log in /var/log/foreman-proxy/proxy.log or if you prefer in the UI at “Infrastructure > Smart Proxies”. There should be some kind of error message causing the error you see in Foremen.

As Dirk already mentioned, it’s hard to help without the log messages.
Still, an error 400 usually indicates an error in either DHCP or Foreman smart-proxy/subnet setup.
Some general pointers:

If you are sure everything is set up correctly and it still does not work, post the log messages from when you try to recieve a free IP as per Dirks post.

Alright, next time I am at my office, I’ll check foreman again and post the logs here to get more help on it.

I have good news, I was able to recreate the same situation I am running into at my work computer here at home in a VM,

Funny enough, I am glad to see the same error as I do at work so I can get the answer and take it back to work tomorrow to fix this! :smiley:

2022-12-15T11:15:48 8135aa67 [I] Logging file reopened via USR1 signal
2022-12-15T11:17:55 5d49f825 [I] Started GET /dhcp/192.168.4.0/unused_ip from=192.168.4.3&to=192.168.4.250
2022-12-15T11:17:55 5d49f825 [W] Unable to parse subnets XML: Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory: <Libvirt::ConnectionError>: Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
/usr/share/foreman-proxy/modules/libvirt_common/libvirt_network.rb:16:in `open'
/usr/share/foreman-proxy/modules/libvirt_common/libvirt_network.rb:16:in `connection'
/usr/share/foreman-proxy/modules/libvirt_common/libvirt_network.rb:25:in `find_network'
/usr/share/foreman-proxy/modules/libvirt_common/libvirt_network.rb:21:in `dump_xml'
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:22:in `parse_config_for_subnets'
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:15:in `initialized_subnet_service'
/usr/share/foreman-proxy/modules/dhcp_libvirt/configuration_loader.rb:14:in `block in load_dependency_injection_wirings'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:8:in `instance'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:57:in `get_dependency'
/usr/share/foreman-proxy/modules/dhcp_libvirt/configuration_loader.rb:19:in `block in load_dependency_injection_wirings'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:8:in `instance'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:57:in `get_dependency'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:74:in `block in inject_attr'
/usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:32:in `block in <class:DhcpApi>'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in `block in compile!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in `block (3 levels) in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1042:in `route_eval'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in `block (2 levels) in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1071:in `block in process_route'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in `process_route'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1021:in `block in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in `each'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in `route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1140:in `block in dispatch!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `block in invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1135:in `dispatch!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in `block in call!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `block in invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in `call!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:938:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/method_override.rb:24:in `call'
/usr/share/foreman-proxy/lib/proxy/log.rb:105:in `call'
/usr/share/foreman-proxy/lib/proxy/request_id_middleware.rb:11:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/xss_header.rb:18:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/path_traversal.rb:16:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/json_csrf.rb:26:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/frame_options.rb:31:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/null_logger.rb:11:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/show_exceptions.rb:22:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:218:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1993:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in `block in call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1769:in `synchronize'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/builder.rb:244:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/handler/webrick.rb:95:in `service'
/usr/share/ruby/webrick/httpserver.rb:140:in `service'
/usr/share/ruby/webrick/httpserver.rb:96:in `run'
/usr/share/ruby/webrick/server.rb:307:in `block in start_thread'
/usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2022-12-15T11:17:55 5d49f825 [E] Unable to parse subnets XML: Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
2022-12-15T11:17:55 5d49f825 [W] Error details for Unable to parse subnets XML: Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory: <Proxy::DHCP::Error>: Unable to parse subnets XML: Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:43:in `rescue in parse_config_for_subnets'
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:20:in `parse_config_for_subnets'
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:15:in `initialized_subnet_service'
/usr/share/foreman-proxy/modules/dhcp_libvirt/configuration_loader.rb:14:in `block in load_dependency_injection_wirings'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:8:in `instance'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:57:in `get_dependency'
/usr/share/foreman-proxy/modules/dhcp_libvirt/configuration_loader.rb:19:in `block in load_dependency_injection_wirings'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:8:in `instance'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:57:in `get_dependency'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:74:in `block in inject_attr'
/usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:32:in `block in <class:DhcpApi>'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in `block in compile!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in `block (3 levels) in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1042:in `route_eval'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in `block (2 levels) in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1071:in `block in process_route'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in `process_route'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1021:in `block in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in `each'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in `route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1140:in `block in dispatch!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `block in invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1135:in `dispatch!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in `block in call!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `block in invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in `call!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:938:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/method_override.rb:24:in `call'
/usr/share/foreman-proxy/lib/proxy/log.rb:105:in `call'
/usr/share/foreman-proxy/lib/proxy/request_id_middleware.rb:11:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/xss_header.rb:18:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/path_traversal.rb:16:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/json_csrf.rb:26:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/frame_options.rb:31:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/null_logger.rb:11:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/show_exceptions.rb:22:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:218:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1993:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in `block in call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1769:in `synchronize'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/builder.rb:244:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/handler/webrick.rb:95:in `service'
/usr/share/ruby/webrick/httpserver.rb:140:in `service'
/usr/share/ruby/webrick/httpserver.rb:96:in `run'
/usr/share/ruby/webrick/server.rb:307:in `block in start_thread'
/usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2022-12-15T11:17:55 5d49f825 [W] Unable to parse subnets XML: Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory: <Proxy::DHCP::Error>: Unable to parse subnets XML: Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:43:in `rescue in parse_config_for_subnets'
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:20:in `parse_config_for_subnets'
/usr/share/foreman-proxy/modules/dhcp_libvirt/subnet_service_initializer.rb:15:in `initialized_subnet_service'
/usr/share/foreman-proxy/modules/dhcp_libvirt/configuration_loader.rb:14:in `block in load_dependency_injection_wirings'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:8:in `instance'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:57:in `get_dependency'
/usr/share/foreman-proxy/modules/dhcp_libvirt/configuration_loader.rb:19:in `block in load_dependency_injection_wirings'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:8:in `instance'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:57:in `get_dependency'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:74:in `block in inject_attr'
/usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:32:in `block in <class:DhcpApi>'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1686:in `block in compile!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in `block (3 levels) in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1042:in `route_eval'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1023:in `block (2 levels) in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1071:in `block in process_route'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1069:in `process_route'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1021:in `block in route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in `each'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1018:in `route!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1140:in `block in dispatch!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `block in invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1135:in `dispatch!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in `block in call!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `block in invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `catch'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1112:in `invoke'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:949:in `call!'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:938:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/method_override.rb:24:in `call'
/usr/share/foreman-proxy/lib/proxy/log.rb:105:in `call'
/usr/share/foreman-proxy/lib/proxy/request_id_middleware.rb:11:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/xss_header.rb:18:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/path_traversal.rb:16:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/json_csrf.rb:26:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.2.2/lib/rack/protection/frame_options.rb:31:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/null_logger.rb:11:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/show_exceptions.rb:22:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:218:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1993:in `call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in `block in call'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1769:in `synchronize'
/usr/share/gems/gems/sinatra-2.2.2/lib/sinatra/base.rb:1553:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
/usr/share/gems/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/builder.rb:244:in `call'
/usr/share/gems/gems/rack-2.2.4/lib/rack/handler/webrick.rb:95:in `service'
/usr/share/ruby/webrick/httpserver.rb:140:in `service'
/usr/share/ruby/webrick/httpserver.rb:96:in `run'
/usr/share/ruby/webrick/server.rb:307:in `block in start_thread'
/usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2022-12-15T11:17:55 5d49f825 [I] Finished GET /dhcp/192.168.4.0/unused_ip with 400 (2.06 ms)

Ah, you are using libvirt as the dhcp provider but there is no libvirt running (or at least this is the most likely reason why /var/run/libvirt/libvirt-sock is not existing). I think you are using the wrong provider as this one is meant to be used for development and testing environments to configure the integrated dnsmasq in KVM. So have a look at the different providers and find the correct one for your environment.

Well, then what provider do I use? I wanted the Foreman to be a DHCP and DNS server to provision a server that it’s connected too via a switch.

Does anyone happen to know if this post over at serverfault.com would help me with my issue? Specifically, the second answer down where the guy starts rattling off a bunch of commands.

Foreman DNS Error ERF12-2357 [ProxyAPI::ProxyException]: Unable to set DNS entry

Foreman will never be a DHCP and DNS server, just integrating one via the Smart Proxy. But if you do not have an existing one, using named for DNS and ISC dhcp for DHCP is a good option which can be totally managed by the Foreman Installer so no need for the manual setup done in the serverfault post.

I read online somewhere you can use Bind9 as a Private DNS, but does Foreman need that? Or no? Otherwise, Foreman still doesn’t see the box that’s attached to for provisioning. The boxes have dual port cards.