Get ip address
Page 1 of 113 Replies - 375 Views - Last Post: 05 February 2013 - 02:19 PM
#1
Get ip address
Posted 01 February 2013 - 07:43 PM
but it's no longer "free", so, anyway to get external ip address on string?
Thanks.
Replies To: Get ip address
#2
Re: Get ip address
Posted 01 February 2013 - 09:05 PM
HeBTeMy, on 01 February 2013 - 08:43 PM, said:
but it's no longer "free", so, anyway to get external ip address on string?
Well, there are a few sites that will give you your IP address, one is here.
Or, you could play around with this code.
Private Sub GetIPAddr()
Dim hostName As String
Dim ipAddr() As IPAddress
hostName = System.Net.Dns.GetHostName()
ipAddr = Dns.GetHostAddresses(hostName)
For i = 0 To ipAddr.Count - 1
Debug.Print(CStr(i) & " " & ipAddr(i).ToString)
Next
End Sub
This gives a number of IP addresses. In my case entry 2 is my external IP address (in Hexadecimal), and entries 3 and 4 are internal (LAN) addresses (in Decimal).
#3
Re: Get ip address
Posted 01 February 2013 - 09:26 PM
Appreciated.
#4
Re: Get ip address
Posted 01 February 2013 - 09:41 PM
Using wb As New WebClient
Dim s As String = wb.DownloadString("http://www.whatsmyip.us/showipsimple.php")
MessageBox.Show(s)
End Using
Result = document.write("33.223.445.23")
Full script here.
#5
Re: Get ip address
Posted 02 February 2013 - 07:27 PM
<?php $ipaddress = $_SERVER["REMOTE_ADDR"]; echo $ipaddress ?>
will get and return the ip address as a string. Or, if you're getting the ip address for security, make a php script for logging in and then just simply have it also record the ip address of the person logging in and their username.
But, if you're using it for something else that doesn't require it to be recorded on the server, then simply use that code with your own php file and use regex to extract it.
#6
Re: Get ip address
Posted 02 February 2013 - 09:18 PM
LilGhost, on 02 February 2013 - 08:27 PM, said:
Actually, it returns all the IP addresses associated with the hostname supplied as a string. As I mentioned, the local (LAN) IP and the external (WAN) IP are both returned.
I am interested in your script, though. I am not at all familiar with PHP, and my first question would be to ask how one invokes a PHP script, with or without VB.Net.
.
This post has been edited by lar3ry: 02 February 2013 - 09:19 PM
#7
Re: Get ip address
Posted 03 February 2013 - 11:04 AM
lar3ry, on 02 February 2013 - 09:18 PM, said:
LilGhost, on 02 February 2013 - 08:27 PM, said:
Actually, it returns all the IP addresses associated with the hostname supplied as a string. As I mentioned, the local (LAN) IP and the external (WAN) IP are both returned.
I am interested in your script, though. I am not at all familiar with PHP, and my first question would be to ask how one invokes a PHP script, with or without VB.Net.
.
I wasn't familiar with it either until about a week ago xD anyways, what i'd do is write:
Imports System.Net
Imports System.IO
Imports System.Text.RegularExpressions
Dim req As httpwebrequest = httpwebrequest.create("MyDomain.com/checkIp.php")
req.Method = "GET"
Dim response At Httpwebresponse = DirectCast(req.GetResponse(), Httpwebresponse)
Dim readBackData As String = New StreamReader(response.GetResponseStream()).ReadToEnd
Then carve it out in some regex.
This post has been edited by LilGhost: 03 February 2013 - 11:05 AM
#8
Re: Get ip address
Posted 03 February 2013 - 11:08 AM
#9
Re: Get ip address
Posted 03 February 2013 - 11:18 AM
#10
Re: Get ip address
Posted 03 February 2013 - 11:20 AM
<?php echo $_SERVER["REMOTE_ADDR"]; ?>
Sample on my site: http://www.gunnerinc.com/2.php (this won't be left there long, don't want my server to get hammered) just request that file with HTTP/sockets code and you will get your external IP returned.
#11
Re: Get ip address
Posted 03 February 2013 - 01:07 PM
GunnerInc, on 03 February 2013 - 11:20 AM, said:
<?php echo $_SERVER["REMOTE_ADDR"]; ?>
Sample on my site: http://www.gunnerinc.com/2.php (this won't be left there long, don't want my server to get hammered) just request that file with HTTP/sockets code and you will get your external IP returned.
congrats on replying with exactly what i said.
#12
Re: Get ip address
Posted 03 February 2013 - 01:21 PM
Could i get an example please?
Thank you.
#13
Re: Get ip address
Posted 05 February 2013 - 02:13 PM
I'd much rather see you just appending text to a file on your server.
On your server's php logging file you'd write:
$ipaddress = $_SERVER["REMOTE_ADDR"]; $logfile= 'accessed.txt'; $msg = $ipaddress . "\n"; $fp = fopen($logfile, 'a'); fwrite($fp, $msg); fclose($fp);
#14
Re: Get ip address
Posted 05 February 2013 - 02:19 PM
Where would my credentials be stored? In that .txt file?
I know that is not safe to store in an application, to easy to decompile, that's why i ask.
If there isn't much troble for you to explain me i would appreciate it.
Thanks.
|
|

New Topic/Question
Reply



MultiQuote







|