Find correct Ip address returned by Dns.GetHostEntry

守給你的承諾、 提交于 2019-12-13 16:03:00

问题


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


回答1:


This question & answers may provide some useful information in getting to 'the right' IP address.




回答2:


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.




回答3:


Ok then can you check the firewall settings of the "com2" or test it by turning it off.



来源:https://stackoverflow.com/questions/6447666/find-correct-ip-address-returned-by-dns-gethostentry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!