Windows DNS smart proxy does not delete A records

Problem:
After some upgrades from Foreman (and Proxies) from version 2.0 to 3.2 the Windows DNS proxy (I am using dns_dnscmd provider) does not work correctly anymore. It looks like it is able to create A and PTR records when provisioning VMs, but not when it is about the deletion. At least the A record stays there and Foreman provides an error message.

Expected outcome: Smart proxy should be able to delete the DNS entries.

Foreman and Proxy versions: 3.2

Foreman and Proxy plugin versions: 3.2

Distribution and version: Ubuntu 20.04 LTS Foreman server / Windows Server Datacenter 2019 Foreman proxy

Other relevant data:

The legacy ui in Foreman tells this error while trying to delete:

Remove Reverse IPv4 DNS record for fraitvm998.DOMAIN.com task failed with the following error: ERF12-1261 [ProxyAPI::ProxyException]: Unable to delete DNS entry ([RestClient::BadRequest]: 400 Bad Request) for proxy https://foreman-proxy.DOMAIN.com:8443/dns

In the new UI btw I didn’t find an error message like this. Just a short version that didn’t help.
It just tells Request failed with status code 422.

The Windows smart proxy logs are telling:

2022-11-02T16:44:50  [D] accept: 10.10.2.118:45770
2022-11-02T16:44:50  [D] Rack::Handler::WEBrick is invoked.
2022-11-02T16:44:51 e0b2e1ff [I] Started DELETE /dns/fraitvm998.ad1.DOMAIN.com/A 
2022-11-02T16:44:51 e0b2e1ff [D] verifying remote client 10.10.2.118 against trusted_hosts ["rmvm069.ad1.DOMAIN.com"]
2022-11-02T16:44:51 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumZones"]
2022-11-02T16:44:52 e0b2e1ff [D] Enumerated authoritative dns zones: ["_msdcs.ad1.DOMAIN.com", "0.0.1.8.e.7.9.3.0.8.a.1.1.0.0.2.ip6.arpa", "0.7.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "0.7.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.0.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "1.0.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.25.172.in-addr.arpa", "10.10.in-addr.arpa", "30.10.in-addr.arpa", "40.10.in-addr.arpa", "6.6.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "6.6.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "65.21.172.in-addr.arpa", "65.22.172.in-addr.arpa", "66.21.172.in-addr.arpa", "66.22.172.in-addr.arpa", "67.21.172.in-addr.arpa", "68.21.172.in-addr.arpa", "69.21.172.in-addr.arpa", "70.21.172.in-addr.arpa", "70.22.172.in-addr.arpa", "71.21.172.in-addr.arpa", "72.21.172.in-addr.arpa", "72.22.172.in-addr.arpa", "ad1.DOMAIN.com", "psp.ad1.DOMAIN.com", "TrustAnchors"]
2022-11-02T16:44:52 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumRecords", "ad1.DOMAIN.com", "fraitvm998.ad1.DOMAIN.com.", "/Type", "A"]
2022-11-02T16:44:52 e0b2e1ff [D] Extracting record from dnscmd output ''
2022-11-02T16:44:52 e0b2e1ff [D] No DNS record found in this line
2022-11-02T16:44:52 e0b2e1ff [D] Extracting record from dnscmd output 'Returned records:'
2022-11-02T16:44:52 e0b2e1ff [D] No DNS record found in this line
2022-11-02T16:44:52 e0b2e1ff [D] Extracting record from dnscmd output '@		 3600 A	172.21.65.98'
2022-11-02T16:44:52 e0b2e1ff [D] Found record '172.21.65.98'
2022-11-02T16:44:52 e0b2e1ff [D] Extracting record from dnscmd output ''
2022-11-02T16:44:52 e0b2e1ff [D] No DNS record found in this line
2022-11-02T16:44:52 e0b2e1ff [D] Extracting record from dnscmd output 'Command completed successfully.'
2022-11-02T16:44:52 e0b2e1ff [D] No DNS record found in this line
2022-11-02T16:44:52 e0b2e1ff [D] Extracting record from dnscmd output ''
2022-11-02T16:44:52 e0b2e1ff [D] No DNS record found in this line
2022-11-02T16:44:52 e0b2e1ff [D] Enumerated 1 A records for zone=ad1.DOMAIN.com node=fraitvm998.ad1.DOMAIN.com records=["172.21.65.98"]
2022-11-02T16:44:52 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/RecordDelete", "ad1.DOMAIN.com", "fraitvm998.ad1.DOMAIN.com.", "A", "172.21.65.98", "/f"]
2022-11-02T16:44:52 e0b2e1ff [D] Removed 172.21.65.98 A record fraitvm998.ad1.DOMAIN.com from ad1.DOMAIN.com
2022-11-02T16:44:52 e0b2e1ff [I] Finished DELETE /dns/fraitvm998.ad1.DOMAIN.com/A with 200 (1650.55 ms)
2022-11-02T16:44:52  [D] accept: 10.10.2.118:45782
2022-11-02T16:44:52  [D] close: 10.10.2.118:45770
2022-11-02T16:44:52  [D] Rack::Handler::WEBrick is invoked.
2022-11-02T16:44:52 e0b2e1ff [I] Started DELETE /dns/98.65.21.172.in-addr.arpa 
2022-11-02T16:44:52 e0b2e1ff [D] verifying remote client 10.10.2.118 against trusted_hosts ["rmvm069.ad1.DOMAIN.com"]
2022-11-02T16:44:52 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumZones"]
2022-11-02T16:44:53 e0b2e1ff [D] Enumerated authoritative dns zones: ["_msdcs.ad1.DOMAIN.com", "0.0.1.8.e.7.9.3.0.8.a.1.1.0.0.2.ip6.arpa", "0.7.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "0.7.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.0.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "1.0.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.25.172.in-addr.arpa", "10.10.in-addr.arpa", "30.10.in-addr.arpa", "40.10.in-addr.arpa", "6.6.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "6.6.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "65.21.172.in-addr.arpa", "65.22.172.in-addr.arpa", "66.21.172.in-addr.arpa", "66.22.172.in-addr.arpa", "67.21.172.in-addr.arpa", "68.21.172.in-addr.arpa", "69.21.172.in-addr.arpa", "70.21.172.in-addr.arpa", "70.22.172.in-addr.arpa", "71.21.172.in-addr.arpa", "72.21.172.in-addr.arpa", "72.22.172.in-addr.arpa", "ad1.DOMAIN.com", "psp.ad1.DOMAIN.com", "TrustAnchors"]
2022-11-02T16:44:53 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumRecords", "65.21.172.in-addr.arpa", "98.65.21.172.in-addr.arpa.", "/Type", "PTR"]
2022-11-02T16:44:53 e0b2e1ff [E] Command dnscmd failed:


DNS Server failed to enumerate records for node 98.65.21.172.in-addr.arpa..

    Status = 9714 (0x000025f2)

Command failed:  DNS_ERROR_NAME_DOES_NOT_EXIST     9714    0x25F2



2022-11-02T16:44:53 e0b2e1ff [E] Command dnscmd failed:


DNS Server failed to enumerate records for node 98.65.21.172.in-addr.arpa..

    Status = 9714 (0x000025f2)

Command failed:  DNS_ERROR_NAME_DOES_NOT_EXIST     9714    0x25F2



2022-11-02T16:44:53 e0b2e1ff [E] Unknown error while processing ''
2022-11-02T16:44:53 e0b2e1ff [W] Error details for Unknown error while processing '': <Proxy::Dns::Error>: Unknown error while processing ''
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:76:in `rescue in report'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:57:in `report'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:53:in `execute'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:111:in `enum_records'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:28:in `do_remove'
C:/Program Files/smart-proxy/modules/dns_common/dns_common.rb:95:in `remove_ptr_record'
C:/Program Files/smart-proxy/modules/dns/dns_api.rb:68:in `block in <class:Api>'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1684:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1684:in `block in compile!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1002:in `block (3 levels) in route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1020:in `route_eval'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1002:in `block (2 levels) in route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1051:in `block in process_route'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1049:in `catch'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1049:in `process_route'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1000:in `block in route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:997:in `each'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:997:in `route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1121:in `block in dispatch!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `catch'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `invoke'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1116:in `dispatch!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:932:in `block in call!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `catch'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `invoke'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:932:in `call!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:921:in `call'
C:/Program Files/smart-proxy/lib/proxy/log.rb:105:in `call'
C:/Program Files/smart-proxy/lib/proxy/request_id_middleware.rb:11:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/xss_header.rb:20:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/path_traversal.rb:18:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/json_csrf.rb:28:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/base.rb:53:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/base.rb:53:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/frame_options.rb:33:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/null_logger.rb:11:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/show_exceptions.rb:23:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:219:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1995:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1554:in `block in call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1770:in `synchronize'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1554:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/builder.rb:244:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/handler/webrick.rb:95:in `service'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webrick-1.7.0/lib/webrick/httpserver.rb:140:in `service'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webrick-1.7.0/lib/webrick/httpserver.rb:96:in `run'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webrick-1.7.0/lib/webrick/server.rb:310:in `block in start_thread'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2022-11-02T16:44:53 e0b2e1ff [W] Unknown error while processing '': <Proxy::Dns::Error>: Unknown error while processing ''
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:76:in `rescue in report'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:57:in `report'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:53:in `execute'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:111:in `enum_records'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:28:in `do_remove'
C:/Program Files/smart-proxy/modules/dns_common/dns_common.rb:95:in `remove_ptr_record'
C:/Program Files/smart-proxy/modules/dns/dns_api.rb:68:in `block in <class:Api>'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1684:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1684:in `block in compile!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1002:in `block (3 levels) in route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1020:in `route_eval'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1002:in `block (2 levels) in route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1051:in `block in process_route'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1049:in `catch'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1049:in `process_route'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1000:in `block in route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:997:in `each'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:997:in `route!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1121:in `block in dispatch!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `catch'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `invoke'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1116:in `dispatch!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:932:in `block in call!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `catch'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1092:in `invoke'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:932:in `call!'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:921:in `call'
C:/Program Files/smart-proxy/lib/proxy/log.rb:105:in `call'
C:/Program Files/smart-proxy/lib/proxy/request_id_middleware.rb:11:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/xss_header.rb:20:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/path_traversal.rb:18:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/json_csrf.rb:28:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/base.rb:53:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/base.rb:53:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-protection-3.0.2/lib/rack/protection/frame_options.rb:33:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/null_logger.rb:11:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/head.rb:12:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/show_exceptions.rb:23:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:219:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1995:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1554:in `block in call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1770:in `synchronize'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sinatra-3.0.2/lib/sinatra/base.rb:1554:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in `block in call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `each'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/builder.rb:244:in `call'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rack-2.2.4/lib/rack/handler/webrick.rb:95:in `service'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webrick-1.7.0/lib/webrick/httpserver.rb:140:in `service'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webrick-1.7.0/lib/webrick/httpserver.rb:96:in `run'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/webrick-1.7.0/lib/webrick/server.rb:310:in `block in start_thread'
C:/Program Files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2022-11-02T16:44:53 e0b2e1ff [I] Finished DELETE /dns/98.65.21.172.in-addr.arpa with 400 (452.82 ms)
2022-11-02T16:44:53  [D] close: 10.10.2.118:45782
2022-11-02T16:44:53  [D] accept: 10.10.2.118:45792
2022-11-02T16:44:53  [D] Rack::Handler::WEBrick is invoked.
2022-11-02T16:44:53 e0b2e1ff [I] Started POST /dns/ 
2022-11-02T16:44:53 e0b2e1ff [D] verifying remote client 10.10.2.118 against trusted_hosts ["rmvm069.ad1.DOMAIN.com"]
2022-11-02T16:44:54 e0b2e1ff [D] Finished DNS query getresources for 'fraitvm998.ad1.DOMAIN.com' in 404.9 ms
2022-11-02T16:44:54 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumZones"]
2022-11-02T16:44:56 e0b2e1ff [D] Enumerated authoritative dns zones: ["_msdcs.ad1.DOMAIN.com", "0.0.1.8.e.7.9.3.0.8.a.1.1.0.0.2.ip6.arpa", "0.7.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "0.7.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.0.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "1.0.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.25.172.in-addr.arpa", "10.10.in-addr.arpa", "30.10.in-addr.arpa", "40.10.in-addr.arpa", "6.6.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "6.6.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "65.21.172.in-addr.arpa", "65.22.172.in-addr.arpa", "66.21.172.in-addr.arpa", "66.22.172.in-addr.arpa", "67.21.172.in-addr.arpa", "68.21.172.in-addr.arpa", "69.21.172.in-addr.arpa", "70.21.172.in-addr.arpa", "70.22.172.in-addr.arpa", "71.21.172.in-addr.arpa", "72.21.172.in-addr.arpa", "72.22.172.in-addr.arpa", "ad1.DOMAIN.com", "psp.ad1.DOMAIN.com", "TrustAnchors"]
2022-11-02T16:44:56 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/RecordAdd", "ad1.DOMAIN.com", "fraitvm998.ad1.DOMAIN.com.", "A", "172.21.65.98"]
2022-11-02T16:44:56 e0b2e1ff [D] Added A entry fraitvm998.ad1.DOMAIN.com => 172.21.65.98
2022-11-02T16:44:56 e0b2e1ff [I] Finished POST /dns/ with 200 (2865.41 ms)
2022-11-02T16:44:56  [D] close: 10.10.2.118:45792

Interesting here is:

2022-11-02T16:44:52 e0b2e1ff [D] Removed 172.21.65.98 A record fraitvm998.ad1.DOMAIN.com from ad1.DOMAIN.com

Then:

2022-11-02T16:44:53 e0b2e1ff [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumRecords", "65.21.172.in-addr.arpa", "98.65.21.172.in-addr.arpa.", "/Type", "PTR"]
2022-11-02T16:44:53 e0b2e1ff [E] Command dnscmd failed:


DNS Server failed to enumerate records for node 98.65.21.172.in-addr.arpa..

    Status = 9714 (0x000025f2)

Command failed:  DNS_ERROR_NAME_DOES_NOT_EXIST     9714    0x25F2

And
2022-11-02T16:44:56 e0b2e1ff [D] Added A entry fraitvm998.ad1.DOMAIN.com => 172.21.65.98

Which might explain where the A record is there again. But why is dnscmd convinced it can’t delete the PTR, but it is actually deleted?

I can say for sure it is working with 3.0.2. Could it be possible that some configs in the smart proxy or the settings of the modules have to be changes?

There have been changes:

$ git log 3.0.2..3.2.0 ./modules/dns_dnscmd/
commit 23bb5a07c694388ff05213b3a5b30c015c11ecf4
Author: Lukas Zapletal <lzap+git@redhat.com>
Date:   Thu Jan 13 14:10:59 2022 +0100

    Refs #34226 - dnscmd nil string error
    
    Signed-off-by: Lukas Zapletal <lzap+git@redhat.com>

commit f88024edf5f24f92a0b7ab98d64b58e4b61e3e4c
Author: Lukas Zapletal <lzap+git@redhat.com>
Date:   Tue Jan 11 08:53:27 2022 +0100

    Refs #34226 - dnscmd nil string error

commit 7b3508a8444c04148f6c99f426a5de5d805f99a6
Author: Lukas Zapletal <lzap+git@redhat.com>
Date:   Thu Jan 6 12:12:23 2022 +0100

    Fixes #34226 - dnscmd nil string error

commit 9522669b7287b62a8bc073f6f8abb5554184e57d
Author: Anna Vitova <avitova@avitova.remote.csb>
Date:   Fri Aug 6 11:52:29 2021 +0200

    fixes #4026 - fixes #4026 secure Windows command execution

This is probably the most significant:

I don’t have access to a Windows DNS server so I can’t really comment, but this line looks suspicious:

I’m getting the feeling there should be no trailing dot in the zone name. However, that appears to be unchanged compared to the previous version.

I have no idea how this ruby stuff works. Is the module included in the smart-proxy binary?
Or does the bin load the module when it gets started? Then I could just change the code in the module and give it a try, right?

Ruby is interpreted so it’s perfectly valid to modify the files and restart the application.

We are talking here about line 22, right? fixes #4026 - fixes #4026 secure Windows command execution · theforeman/smart-proxy@9522669 · GitHub

So "#{name}." vs "#{name}", right?

If so we run in the reverse issue since then deleting A records (sounds weird, since the initial issue was was about deleting A records, but as we’ve seen in the logs above the proxy is creating again an A record).

2022-11-04T15:18:45  [D] Rack::Handler::WEBrick is invoked.
2022-11-04T15:18:45 c0c8dcc0 [I] Started DELETE /dns/fraitvm998.ad1.DOMAIN.com/A 
2022-11-04T15:18:45 c0c8dcc0 [D] verifying remote client 10.10.2.118 against trusted_hosts ["rmvm069.ad1.DOMAIN.com"]
2022-11-04T15:18:46 c0c8dcc0 [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumZones"]
2022-11-04T15:18:46 c0c8dcc0 [D] Enumerated authoritative dns zones: ["_msdcs.ad1.DOMAIN.com", "0.0.1.8.e.7.9.3.0.8.a.1.1.0.0.2.ip6.arpa", "0.7.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "0.7.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.0.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "1.0.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "1.25.172.in-addr.arpa", "10.10.in-addr.arpa", "30.10.in-addr.arpa", "40.10.in-addr.arpa", "6.6.0.0.1.0.4.0.8.7.d.4.1.0.0.2.ip6.arpa", "6.6.0.0.2.0.0.1.0.f.6.f.7.0.6.2.ip6.arpa", "65.21.172.in-addr.arpa", "65.22.172.in-addr.arpa", "66.21.172.in-addr.arpa", "66.22.172.in-addr.arpa", "67.21.172.in-addr.arpa", "68.21.172.in-addr.arpa", "69.21.172.in-addr.arpa", "70.21.172.in-addr.arpa", "70.22.172.in-addr.arpa", "71.21.172.in-addr.arpa", "72.21.172.in-addr.arpa", "72.22.172.in-addr.arpa", "ad1.DOMAIN.com", "psp.ad1.DOMAIN.com", "TrustAnchors"]
2022-11-04T15:18:46 c0c8dcc0 [D] executing: ["c:\\Windows\\System32\\dnscmd.exe", "localhost", "/EnumRecords", "ad1.DOMAIN.com", "fraitvm998.ad1.DOMAIN.com.", "/Type", "A"]
2022-11-04T15:18:46 c0c8dcc0 [E] Command dnscmd failed:


DNS Server failed to enumerate records for node fraitvm998.ad1.DOMAIN.com..

    Status = 9714 (0x000025f2)

Command failed:  DNS_ERROR_NAME_DOES_NOT_EXIST     9714    0x25F2



2022-11-04T15:18:46 c0c8dcc0 [E] Command dnscmd failed:


DNS Server failed to enumerate records for node fraitvm998.ad1.DOMAIN.com..

    Status = 9714 (0x000025f2)

Command failed:  DNS_ERROR_NAME_DOES_NOT_EXIST     9714    0x25F2

2022-11-04T15:18:46 c0c8dcc0 [E] Unknown error while processing ''
2022-11-04T15:18:46 c0c8dcc0 [W] Error details for Unknown error while processing '': <Proxy::Dns::Error>: Unknown error while processing ''
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:76:in `rescue in report'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:57:in `report'
C:/Program Files/smart-proxy/modules/dns_dnscmd/dns_dnscmd_main.rb:53:in `execute'

I think what actually may be happening is this:

I think that’s intended to ignore this message, but perhaps the message changed? Note how it says DNS Server failed to enumerate records for node but checks for Failed to EnumRecords.

I can just say, that now the A record is gone and the PTR is still there.

To fix this issue: Refs #34226 - dnscmd nil string error by sbernhard · Pull Request #855 · theforeman/smart-proxy · GitHub