DNS lookup with KNIME

Dear KNIMErs,

I’d like to do a series of (automated/looped) DNS lookups with KNIME - any ideas of how I could go about doing that?

Many thanks,

Depending on what exactly you want to achieve, using the java.net.InetAddress class may already be enough. You may even use it from inside the Java Snippet node.

1 Like

Works like a charm, many thanks! :slight_smile:

In case anyone’s interested in a code sample working with KNIME 2.1.2, here you go (think of other non-programmers like me):

/* Please note that as of KNIME 2.0  * you must use the "return" keyword  * to specify the return value.  */   String exists; InetAddress addr; String host = "java.suuun.com";   try {   addr = InetAddress.getByName(host);   exists = "Y"; } catch (UnknownHostException e){   exists = "N"; }   return exists;


1 Like

Hi. For me it is the first time using a Java Snippet. Unfortunately the information from @Ergonomist does not fit to my knowledge level. May you can share a screenshoot how to code has to put to the Snippet Node. I have installed KNIME 4.2.
Many thanks in advance

Hi there,

It’s been over a decade, yet it still works – demo workflow attached. :smiley:

DNS lookup.knwf (6.6 KB)



Thank you @Ergonomist. knwf successfully imported and it works fine. Now I need to modify the method body to 1) resolve hostnames to IP adresses and 2) vice versa.
I tried to do it but I’m am at the beginning of learning and getting error messages. I changed it as follow. May you support me again?!

/* Please note that as of KNIME 2.0  * you must use the "return" keyword  * to specify the return value.  */   
Byte exists; 
InetAddress addr; 
String host = $URL$;   

try {   
	addr = InetAddress.getAddress(host);   
	exists = addr; 
catch (UnknownHostException e) {
	exists = "N"; }

return exists;

1 Like

Awesome! Post of the month. :slight_smile:


Hi @uidf7346,
You had some type issues in your script, I created a workflow that fixes them, I used the Java Snippet node as it provides you with better help during script development. Take a look here:



Thanks! As I said – non-coder and StackOverflow squirrel here… :wink:


1 Like

Is there any way to have a ping as column?

www.knime.com Y
www.knime11122.com N

1 Like

H @natanzi ,

I think it would be a good feature to have. However, what would be the purpose of the ping? I mean what would be Y and N?

The dns lookup is different and the access is also different.

A dns lookup will do a lookup into the domain registrar, while a ping will actually hit the server of the address, and if the server is behind a firewall, your ping would return nothing as it’s not able to reach the server, but a dns lookup will return you something if that domain or ip exists.

Also, ping returns different information, so I’m still not sure what Y and N represents, or rather I should say when should it return Y and when should it return N

1 Like

Dear @bruno29a

Many thanks for your clarification, You are right; if the server is behind the firewall, It does not return anything, So in this case, it is not applicable; while it has a valuable feature,

The Result which I have in my mind is If the IP/URL has a ping result, it would be :Y ( yes ), and if the ping would not be reached, the Result would be: N (No)



1 Like

Hi @natanzi , ok it could make sense that if the server is reachable then the result is Y, and otherwise N.

But what’s the configuration of the ping like though? What would be the packet size and how many ping should be sent? Most OS’s don’t send just 1 ping. For example, Windows I think send 4 or 5 pings, and then give you a percentage results depending on how many of the 4 or 5 were reachable. In Linux, and I assume on MacOS would be the same, it keeps pinging until you actually break (CTRL-C) it. Would it be just 1 ping in Knime’s case? If it’s just 1 ping, it will simply calculate the reachability at THAT time (when it executed) - while each ping would also actually calculate the reachability at the time it ran, running several pings show patterns of the connectivity (hence why OS’s send multiple pings).

Also, as I mentioned, ping returns other information such as the ttl and the response time.

As I said, I think it can be a great feature, but I’m not sure how it should be implemented. And to also re-iterate what I said, it’s different from a dns lookup. Great feature to have, but it should not be used to replace a dns lookup.

1 Like

Dear @bruno29a
Thanks for your reply, The knime configuration for the Ping service is complicated; how about using Free API or implementing an Online service in Python node? I try it.

DNS lookup is excellent, and I use it in my flow; perfect! its apart from Ping.

1 Like