11-20-2012 05:44 PM
Hi,
Im using a code avaible in NI Database, wich close the connection from a user to a remote panel, if the connections limit is exceeded.Here is the Link
The code isn't working for me, because it doesnt convert the hostname into a valid IP adress, so I can block this IP.
To do this, I used the blocks to convert IP to string, and then String to IP. When I access the panel in LAN mode, works fine, the ip apperars correctly, but when I acess it remotely, the IP appears a little messy. i.e: Real IP with hostname 189-99-29-228.user.vivozap.com.br , IP that appears on labview probe : 41.224.89.10
I've attached mi VI, to you guys take a look!
Cheers
11-21-2012 12:52 AM
Hi! Maybe this is due to multiple network interfaces.
Try setting "String to IP" to multiple output mode (see the option appearing when you right click the VI).
From the help:
"
If String To IP is in single output mode, the net address is
the first result returned by the operating system resolver. If String To IP is
in multiple output mode, the result is an array of all IP network addresses
returned by the operating system resolver. If the node fails to convert the
string, the result is a value of zero in single output mode or an empty array in
multiple output mode.
"
Regards,
Marco
11-21-2012 07:33 AM
I tryed this Marco, check the result. The results of the conversions are inside the black circles.
Dont know what to do anymore.
11-21-2012 08:02 AM
Is this the value for the string in the 2nd element of the array of clusters?
189-99-29-228.user.vivozap.com.br
Or are you saying that the top IP address is correct? You do realize that you are indexing 2 different elements, right?
11-21-2012 12:08 PM
No, the top IP is uncorrect.
What i need to get from 189-99-29-228.user.vivozap.com.br is "189.99.29.228". But it only happens if I access the VI in LAN mode, not in remote access.
Any suggestion?
11-21-2012 01:19 PM
@fabioalmeidaa wrote:
No, the top IP is uncorrect.
What i need to get from 189-99-29-228.user.vivozap.com.br is "189.99.29.228". But it only happens if I access the VI in LAN mode, not in remote access.
Any suggestion?
I'm surprised you get anyting from the VI at all. The String to IP is used to resolve either a name or convert a dotted notation IP address to a single number. You are combingin both. A name would use DNS to resolve the IP address and then convert that to a number. Either pass the String to IP "189.99.29.228" or "user.vivozap.com.br". If you do a nslookup from the command line using "189-99-29-228.user.vivozap.com.br" what do you get as a result?
11-21-2012 01:22 PM - edited 11-21-2012 01:23 PM
If the node fails to convert the string, the result is a value of zero in single output mode or an empty array in multiple output mode.
Is the leading part of the address always the same? If so, you may need to create your own filter.
EDIT: As Mark said...
11-21-2012 02:44 PM
Sorry guys, I don't have much knowledge in network area. I followed this example to make the conversion: http://digital.ni.com/public.nsf/allkb/3C7D65E2A95C52FD86256F37006F67C9
No, the leading part is not always the same, multiple users will access this vi, so the leading part will change always. This multiple output vi that i attached is just to show Marco(the guy on the 2nd post) that his tip didn't worked also.
The original VI is attached in my first post. Without multiple output method.
I really don't know what to do anymore. And its really strange that in LAN works fine!
The result from nslookup:
Microsoft Windows [versão 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Todos os direitos reservados.
C:\Users\Usuario>nslookup
Servidor PadrÒo: ns1.recursive.dns.com
Address: 8.26.56.26
> nslookup 189-99-29-228.user.vivozap.com.br
Servidor: 189-99-29-228.user.vivozap.com.br
Addresses: fe80:1::225:90ff:fe19:4b12
92.242.144.50
*** 189-99-29-228.user.vivozap.com.br não encontrou nslookup: No response from s
erver
11-21-2012 03:19 PM
The correct use of nslookup is to run "nslookup" as you've done, and then just put the name you want to look up after the > prompt. Don't put "nslookup" again.
Can you clarify what you mean by "LAN" versus "remote"? Are these different networks? It's possible there's a proxy, filter, or firewall on one network that is returning what you think is an incorrect IP address. From the LAN configuration, where it's working properly, run nslookup and see what server it's using. Then, in your "remote" configuration, run nslookup, and at the > prompt put "server [server ip]" where the server IP is the one you noted from the LAN configuration. After that run the lookup again (don't exit nslookup, just put the hostname at the next > prompt). See if you get the expected result.
In any case, it sounds like this is a networking issue, not a problem specific to LabVIEW.
11-21-2012 06:34 PM
I mean LAN when i use a laptop in my home network to access, and remote when I use a machine from a different location.