11-26-2014 12:21 AM - edited 11-26-2014 12:24 AM
Hi, I have one computer with two network cards. one is connected to a server. Another is connected with one local area network.
Is there a method to know the IP address of the network card that is used to communicate with the server?
For example, in the attached network, I want to get the IP address 10.48.22.54 for PC1.
11-26-2014 01:23 AM
I believe executing ipconfig command in system Exec.vi would get you the connected IP address.
11-26-2014 01:35 AM
Thanks for your reply, Anand!
From ipconfig, seems like I can't know which one is the correct one.
I'd like to write code by myself. I need to know a solution first. 🙂
11-26-2014 02:25 AM
"String to IP" can be configured to return multiple (all) addresses. Just right-click the primitive and select "Multiple Output". You can then use IP to String to get the IP addresses in a more readable form.
To know which of the 2 is the connection to your server you need to have some knowledge. If you know it starts with "10." you can just pick the IP address that matches this pattern.
11-26-2014 03:25 AM
Thanks, Dan.
Yeah, this is a method. I just want to find a safer way to get the correct IP as maybe there is a case that PC and Server are not in the same subnet.
11-26-2014 03:33 AM
What do you mean by "safer"? Using this function you will get all local IP addresses, whether the server is in a different subnet or not.
11-26-2014 04:11 AM
For example, suppose the test PC has two NICs with IP address 10.48.22.54 and 192.168.1.2. The server address is 14.52.23.147.
How to determine which IP address is the right one?
11-26-2014 04:22 AM
Well you must have some kind of information, else it's just like rolling a dice.
I'm not sure about the setup. Where is the DHCP server if you have a connection to a server but are not in the same subnet? Or are you working with static IP addresses?
I'm not an expert here, but how does the OS know the routing if you're not in the same subnet as the server but try to talk to it?
11-26-2014 04:31 AM
As I know, ping can be used in this case. The ip address that can ping server successfully is the right one.
What we consider is that server can be configured to refuse other machines ping it.
So want to get help from the community to see if there is a better solution.
11-26-2014 04:59 AM