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.
I believe executing ipconfig command in system Exec.vi would get you the connected IP address.
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. 🙂
"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.
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.
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.
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 126.96.36.199.
How to determine which IP address is the right one?
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?
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.