1. If you use a route to access the Internet, you can access an IP address such as ip138 to obtain an Internet IP address.
2. If you use pppoe to dial up the Internet, you can use the following code to obtain the IP Address:
// Obtain the IP address of the bandwidth connection (pppoe dial-up), timeout (seconds). When the bandwidth is not connected or the connection is in progress, the public static string getip_pppoe (INT timeout) ip address cannot be obtained) {int I = timeout * 2; while (I> 0) {try {networkinterface [] timeout = networkinterface. getallnetworkinterfaces (); bool havepppoe = false; foreach (networkinterface adapter in requests) {If (adapter. networkinterfacetype = networkinterfacetype. PPP) {havepppoe = true; ipinterfaceproperties IP = adapt Er. getipproperties (); // ip configuration information if (IP. unicastaddresses. count> 0) {return IP. unicastaddresses [0]. address. tostring () ;}}// if (! Havepppoe) Return "";} catch (exception ex) {console. writeline ("An error occurred while obtaining the bandwidth dial-up IP Address:" + ex. message);} I --; thread. sleep (500);} return "";}