Alex Rivera | Logout

How to get *internet* IP?

Asked 2009-02-05T11:02:49.303
14

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# ?

Edit
Report

2 Answers

2

A hacky way is to fetch and scrape one of the many 'What Is My IP' type websites.

answered 2009-02-05T11:05:33.167
0

Use tracert. The first hop should always be on the same subnet as your internet NIC.

example from command prompt.

tracert google.com

the first line is 10.0.0.254 and my nic has the ip of 10.0.2.48. Then it is a simple exercise of parsing the output from tracert.

answered 2009-12-07T12:03:40.667

Your Answer