LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get ip address to one server when there are multiple network cards on the same computer

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.

0 Kudos
Message 1 of 16
(4,137 Views)

I believe executing ipconfig command in system Exec.vi would get you the connected IP address.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 16
(4,108 Views)

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. 🙂

0 Kudos
Message 3 of 16
(4,091 Views)

"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.

MultipleIPAddr.png

Message 4 of 16
(4,070 Views)

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.

 

0 Kudos
Message 5 of 16
(4,054 Views)

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.

 

0 Kudos
Message 6 of 16
(4,049 Views)

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?

0 Kudos
Message 7 of 16
(4,036 Views)

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?

 

0 Kudos
Message 8 of 16
(4,033 Views)

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.

0 Kudos
Message 9 of 16
(4,024 Views)
I believe what you want is the "route" command. Try running it from the command line with the -p option. You can provide an IP address on the command line as well and it will show just the interface that will be used to route to that address.
0 Kudos
Message 10 of 16
(4,010 Views)