How to specify DNS server port number for Smart Proxy "nsupdate" provider?

There is no foreman installer directive like –foreman-proxy-dns-server-port to specify what DNS port nsupdate must use during provisioning.

My DNS server uses a non-standard UDP port for listening to DDNS updates. By default nsupdate uses port 53/udp but this behaviour can be changed by specifying -p or in “server” command - see below man info:

server servername [ port ]
Sends all dynamic update requests to the name server servername. […skipped…] If no port number is specified, the default DNS port number of 53 is used.

Also -p command line parameter can be used - works for nsupdate 9.11.36

P.S. I’ve tested both port approaches manually from TheForeman host and they both worked fine.

I’ve tried to specify port for Foreman as shown in above man example (i.e. serverport)

# Configuration file for 'nsupdate' dns provider

:dns_key: /etc/foreman-proxy/rndc.key
# use this setting if you are managing a dns server which is not localhost though this proxy
:dns_server: 8953

but DNS record creation failed with the below diagnostic (kinda expected)

2023-09-21T12:52:06 70ac10ff [E] getaddrinfo: Name or service not known
2023-09-21T12:52:06 70ac10ff [W] Error details for getaddrinfo: Name or service not known: : getaddrinfo: Name or service not known
/usr/share/ruby/resolv.rb:827:in connect' /usr/share/ruby/resolv.rb:827:in block in lazy_initialize’
/usr/share/ruby/resolv.rb:819:in synchronize' /usr/share/ruby/resolv.rb:819:in lazy_initialize’
/usr/share/ruby/resolv.rb:839:in sender' /usr/share/ruby/resolv.rb:527:in block in fetch_resource’
/usr/share/ruby/resolv.rb:1125:in block (3 levels) in resolv' /usr/share/ruby/resolv.rb:1123:in each’
/usr/share/ruby/resolv.rb:1123:in block (2 levels) in resolv' /usr/share/ruby/resolv.rb:1122:in each’
/usr/share/ruby/resolv.rb:1122:in block in resolv' /usr/share/ruby/resolv.rb:1120:in each’
/usr/share/ruby/resolv.rb:1120:in resolv' /usr/share/ruby/resolv.rb:521:in fetch_resource’
/usr/share/ruby/resolv.rb:507:in each_resource' /usr/share/ruby/resolv.rb:498:in getresources’

Expected outcome:
Some installer parameter allowing to specify a custom DNS port number for nsupdate.

Foreman and Proxy versions:
Foreman 3.7.0-1.el8

Foreman and Proxy plugin versions:
Foreman 3.7.0-1.el8

Distribution and version:
CentOS8 Stream
Foreman 3.7.0
Katello 4.9.1

Other relevant data:

I’ve looked through the dns_nsupdate provider source code and figured out that it would be easy to fix by adding a new parameter to config file or DNS_SERVER:PORT form.

However I’m not a Ruby programmer nor have a time for that (sorry) - so, I just did a dirty hack in /usr/share/foreman-proxy/modules/dns_nsupdate/dns_nsupdate_main.rb :slight_smile:

 def nsupdate_connect
      find_nsupdate if @nsupdate.nil?
      #nsupdate_cmd = "#{@nsupdate} #{nsupdate_args}"
      nsupdate_cmd = "#{@nsupdate} #{nsupdate_args} -p 8953 "
      logger.debug "running #{nsupdate_cmd}"
      @om = IO.popen(nsupdate_cmd, "r+")
      logger.debug "nsupdate: executed - server #{@server}"
      @om.puts "server #{@server}"

It worked fine fore me.

No one ever responded… :frowning: