Hello everyone! I've looked through all the elements under System.Net.NetworkInformation and I can't seem to find a way to retrieve the client's remote IP address. May someone please explain to me how? Thank you very much!
Printable View
Hello everyone! I've looked through all the elements under System.Net.NetworkInformation and I can't seem to find a way to retrieve the client's remote IP address. May someone please explain to me how? Thank you very much!
Hello again! I've tried the following code, but TextBox4 was blank.
VB Code:
For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections TextBox4.Text = tcpConnection.RemoteEndPoint.Address.ToString() Next
Bump! I've been doing research for hours and I still can't find anything! :( I only found topics relating to retrieving local IP addresses (192.168.x.x). How do I retrieve a remote IP address? If you don't know what I mean by remote IP address, it's the IP address that IP Chicken provides you. Thank you very much!
Cheap way is to have a browser go to www.whatismyip.org and read the document. Don't know how to do it any other way.Quote:
Originally Posted by getlowdogg369
It must be in Visual Basic 2005. This is because I'm making a banning system. Anyone else...?Quote:
Originally Posted by high6
You can do that in vb 2005...Quote:
Originally Posted by getlowdogg369
I can? Great! Do you know how...? If not, I have an alternative idea. What if I retrieved the source code of the website you posted. There is nothing within the source code but the IP address, so yea...Quote:
Originally Posted by high6
Quote:
Originally Posted by getlowdogg369
Code:Imports System.Net
Imports System.Text.Encoding
TextBox1.Text = Nothing
Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Raw, Sockets.ProtocolType.Raw)
tcp.Connect(TextBox2.Text, 80)
If tcp.Connected = False Then Exit Sub
tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & vbCrLf))
Dim buf(1024) As Byte
Dim bytes As Int32 = tcp.Receive(buf, 1024, 0)
TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
Do While bytes > 0
bytes = tcp.Receive(buf, 1024, 0)
TextBox1.Text &= ASCII.GetString(buf, 0, bytes)
Loop
That would give him his IP. Im assuming, by looking at the code that he provided, that he wants to retrieve the IP adresses of all active connections on the PC.
The code you wrote should be working, but try this and see if any IP adresses are showing:
VB Code:
For Each tcpConnection As TcpConnectionInformation In IPGlobalProperties.GetIPGlobalProperties.GetActiveTcpConnections MessageBox.Show(tcpConnection.RemoteEndPoint.Address.ToString()) Next
The program frozed up when I used the code.Quote:
Originally Posted by high6
I just want to retrieve the remote IP address. Nothing else. If you don't know what I mean by remote IP address, it's the IP address the IP Chicken provides you. Also, your code is providing me with 3 different IP addresses. None of which are my remote IP address.Quote:
Originally Posted by Atheist
you probably used it wrong. imports goes up top and textbox2 is the host(www.whatismyip.org), textbox1 is where its pasted(remote ip).Quote:
Originally Posted by getlowdogg369
Quote:
Originally Posted by high6
That's my exact code straight out of the program. Also, I'm not receiving any errors/warnings. I've typed "www.google.com" without the quotes into TextBox2 and it still frozed. Also, how does this give the client his/her computer's remote IP address? I just want it to do basically the same as IP Chicken or www.whatismyip.org.vb Code:
Imports System.Net Imports System.Text.Encoding Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = Nothing Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Raw, Sockets.ProtocolType.Raw) tcp.Connect(TextBox2.Text, 80) If tcp.Connected = False Then Exit Sub tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & vbCrLf)) Dim buf(1024) As Byte Dim bytes As Int32 = tcp.Receive(buf, 1024, 0) TextBox1.Text &= ASCII.GetString(buf, 0, bytes) Do While bytes > 0 bytes = tcp.Receive(buf, 1024, 0) TextBox1.Text &= ASCII.GetString(buf, 0, bytes) Loop End Sub End Class
Quote:
Originally Posted by getlowdogg369
forgot I changed it when messing around.Code:Dim tcp As New Sockets.Socket(Sockets.AddressFamily.InterNetwork, Sockets.SocketType.Stream, Sockets.ProtocolType.Tcp)
Aghh! I think they blocked it out!:(Quote:
Originally Posted by high6
It works fine with Google!Quote:
HTTP/1.1 200 OK
Connection: close
Content-Length: 159
Date: Mon, 05 Mar 2007 02:02:22 GMT
Content-Type: text/plain
Server: AOLserver/4.0
MIME-Version: 1.0
Error: blank User-Agent header is not allowed! Please ask the author of your IP address checking client to specify their client's name in the User-Agent header
Ahh, well... Does anyone else know any way to retrieve the remote IP address of the client's computer?Quote:
HTTP/1.0 200 OK
Cache-Control: private
Content-Type: text/html
Set-Cookie: PREF=ID=cefed278a818f1ac:TM=1173059501:LM=1173059501:S=dpa82SYisptIk_WP; expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
Server: GWS/2.1
Date: Mon, 05 Mar 2007 01:51:41 GMT
Connection: Close
<html>
<head>
...
</head>
<body>
...
</body>
</html>
Just change the packet being sent to.Quote:
Originally Posted by getlowdogg369
also the first packet is gonna be all that data, the second one will contain the IP.Code:tcp.Send(ASCII.GetBytes("GET / HTTP/1.0" & vbCrLf & "User-Agent: FireFox" & vbCrLf & vbCrLf))
Yes, it works! One more question... How do I make it so it doesn't retrieve the headers? The following is the headers incase you didn't know...Quote:
Originally Posted by high6
How would I make it at least retrieve the last line? Thank you very much!Quote:
HTTP/1.1 200 OK
Connection: close
Content-Length: 13
Date: Mon, 05 Mar 2007 02:12:40 GMT
Content-Type: text/plain
Server: AOLserver/4.0
MIME-Version: 1.0