怎样获得公网IP
一台电脑,通过路由器上网.有指定IP地址,现在想通过程序获得这台电脑的公网IP,请问要怎么做呢?
2007-04-26 11:22
2007-04-26 14:54
2007-04-26 15:17
作为一个方法来处理这个问题...
Sub Main()
Dim strMachineName As String
'得到主机名
strMachineName = Dns.GetHostName()
Console.WriteLine("Host Name: " + strMachineName)
'通过名字得到主机
Dim ipHost As IPHostEntry
ipHost = Dns.GetHostByName(strMachineName)
'以数组的形式返回相关主机的地址信息
Dim ipAddr() As IPAddress = ipHost.AddressList
Dim count As Integer
'Enumerate the IP Addresses
For count = 0 To ipAddr.GetUpperBound(0)
Console.Write("IP 地址 {0}:{1} ", count, _
ipAddr(count).ToString)
Next
End Sub

2007-04-26 16:07
2007-04-27 11:51
2007-04-28 09:06
2007-04-28 09:53
2007-04-28 16:05
2007-04-30 09:56
2007-05-03 14:48