On 2013-04-18 10:18, Mark Rogers wrote:
I'm working with a brain
dead system, so bear with me...
I need a way to do a DNS lookup of
an IP address that returns the IP
address. I can control the DNS
server, and/or possibly apply a suffix
to the IP address.
The
reason is that I have an industrial unit that will accept a
hostname
(for FTP purposes) but if I enter an IP address it fails, and
this
appears to be because its DNS lookup of that address is failing.
The
unit should have Internet access and I can set the DNS server to
whatever I like, so one option would may to run my own DNS server that
when queried for "192.168.1.1" returns the IP address "192.168.1.1".
That pre-supposes that the unit isn't already detecting that
"192.168.1.1" is an IP address, not doing a DNS lookup, but then
failing for some other reason (where it does not fail if I use a name
which looks up to that IP).
A "better" solution is probably to
apply a suffix, so instead of
entering "192.168.1.1" I enter
"192.168.1.1.example.com" [1] where the
DNS for "example.com" will
return the IP address. That way I know that
the unit will be forced to
go through a DNS lookup and is more likely
to just work. I'd just need
some guidance on setting up BIND or some
other DNS to achieve this.
Any ideas?
The "best" option would be to get the manufacturer to
fix their
product but it turns out that the best options aren't always
available
:-(
[1] Just for clarity: the user enters the IP
address and I have no
control over what address they'll enter. In my
code I then detect that
it's an IP address rather than a hostname
(probably just checking
whether the last character is numeric would
suffice), and appending
".example.com" before passing to the FTP
handling code.
Can you do a reverse lookup in your code and provide the correct dns entry to the application?
You'd then only need to set up the relevant zone files in the dns server - a fairly straightforward description of this configuration can be found here: http://www.philchen.com/2007/04/04/configuring-reverse-dns
Hope this helps,
Jim