GetExternalIP – a program for getting external IP address

GetExternalIP - workflow of getting external IP address
image_pdfimage_print

Dear readers of SoftMaker.kz blog. Today I would like to represent a program that helps me to get IP address of my router KEENETIC, in russian without using pay or any other services. A code of the program is based on what described in the post How to get external IP address using Delphi software. Another post of this series describes, how to get computer IP address in a local network using Delphi.

First start of GetExternalIP

Program GetExternalIP is only one file GetExternalIP.exe. In order to get your external IP address you need to have connection to the Internet and just start GetExternalIP.exe. Your external IP address will be shown on the screen in the form of a dialogue.

GetExternalIP - dialogue of an getting external IP address

If you look at the workflow, you may see that we perform only the first and the second points. The second point is half performed since information is not saved in ip.txt file, but there appears a dialogue form with IP address.

At the first start program GetExternalIP works with the default settings. If you want to install your preferred settings and expand the opportunities of the program, you may want to read the following subheading.

Description of the file for setting of GetExternalIP

Settings of GetExternalIP are stored in settings.ini file. The following sections with parameters are recorded on default :

[Main]
SleepTime=0
DisplayIPInDialog=yes
DoNotUseFTP=yes
GetAnExternalIPAddressPhp=http://en.softmaker.kz/get_an_external_ip_address.php
[FTP]
Host=your-ftp-host
Port=21
Username=your-ftp-username
Password=your-ftp-password
FTPDir=your-ftp-dir

Parameters of section [Main]:

  • SleepTime indicates the delay of program start in milliseconds. This parameter should be used when you start the programGetExternalIP at the start of Windows and you are not sure that you will have immediate connection to the Internet.
  • DisplayIPInDialog – if yes is chosen, there will appear a dialogue.
  • DoNotUseFTP – if no is chosen, connection will be done in conformity with user account that is shown in section[FTP]. The file ip.txt will be saved in the catalogue, shown in the parameterFTPDir.
  • GetAnExternalIPAddressPhp – path to the script get_an_external_ip_address.php, that gives you your external IP address. The same script you can put on your web site and write the path in this parameter.

Parameters of section[FTP] contains user account of access to your FTP server. If you bought a hosting, ask a hoster to give you these data, then write them in settings.ini file in section [FTP]:

  • Host – address of your FTP server.
  • Port – port of FTP server. Default – 21, but you can have another.
  • Username – user name to access FTP server.
  • Password – password to access FTP server.
  • FTPDir – path on FTP server where ip.txt file with your IP address will be recorded.

Description of workflow of GetExternalIP program

If you filled in all parameters of section [FTP] and installed parameter DoNotUseFTP of section [Main] in value no, programm GetExternalIP will run in full measure.

In compliance with the workflow:

  1. We get IP address by using script get_an_external_ip_address.php.
  2. Then in dialogue form we get IP address, if parameter DisplayIPInDialog is set in yes. File ip.txt (that contains external IP address) is saved on your computer disk.
  3. ip.txt file that contains your external IP address is recorded through FTP to the address that you indicated in parameter FTPDir.

How to use external IP address that was gotten as a result of operation of GetExternalIP?

Of course there is a question why to record ip.txt file on FTP resource? It is necessary if you want to know your external IP address even if you are in a different place, for example to get access to your computer or external disk (that is connected to the router through USB-port). If your modem or router give access to USB-drive through FTP protocol, you can provide FTP-access to them (in russian), by indicating a user and a password.

Now that you have your external IP address, connected USB-drive, user and password for FTP-access, you can address it from the Internet according to the following pattern: ftp://your-username:[email protected]

For instance: ftp://administrator:12345 @ 222.132.29.57 (spaces before and after [email protected] symbol must be deleted). It is possible to get such address automatically by writing a little script in PHP:

<?php

$fp = fopen("ip.txt", "r"); // Open file in the reading mode
if ($fp)
{
    while (!feof($fp))
    {
        $mytext = trim(fgets($fp, 999));
        $ftp = "ftp://administrator:12345@".$mytext;
        break;
    }
    echo $ftp;
}
else echo "Error opening file";
fclose($fp);

?>

I hope this little program will be of use to you.


  Please, Login or Register to get the download link.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *