Find correct Ip address returned by Dns.GetHostEntry
Suppose there are 2 computers on same network, named com1 and com2.
On com1, if I call
Dns.GetHostEntry("com2")
surely enough, it returns only 1 ip address, like 192.168.1.2, which I could use it to communicate with com2. However, if I call
Dns.GetHostEntry("com1")
It will return all ip addresses (192.168.1.1(the one I want) as well as other addresses like 169.254.100.50 (vm address, I need to filter this out))
The question is, how can I get a unique "real" ip address for com1 in this case?
Thanks in ad开发者_如何学Govance.
After some research this question is actually hard to answer. If "com1“ has multiple NICs, it is hard to find which NIC it uses to communicate with "com2", I have found this SO link to get address on NICs that are connected to internet, VM address will not connect to internet. Obviously asking “com1" itself to find which NIC it uses to connect to "com2" is hard,should rather asking "com2" instead.
Ok then can you check the firewall settings of the "com2" or test it by turning it off.
精彩评论