Imagine a situation, I have PC with two lan cards, one is connected to internet another is connected to local network, how can I detect IP which is connected to internet with C# ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
Note that this implementation of
findMatch()relies on class C matching. If you want to support class B matching, just omit the check foripBytes[2] == gatewayBytes[2].Edit History:
www.example.com.getInternetIPAddress(), to show how to use the other methods.FormatExceptionifgetInternetGateway()failed to parse the gateway IP. (This can happen if the gateway router is configured such that it doesn’t respond to traceroute requests.)