menuimage

Description

Usage

Example

Conffile

Options

Dependencies

License

Changelog

Download

My_Other_Sites

My_Programs

Comments

myip-upload v1.3 [23 May 2017] by Dominic

Description

This is a command-line program for Linux or Windows (with Cygwin - which must have inetutils) to obtain your external ip address and then compare it with the latest entry on a remote file; if it has changed, append the changed ip to the remote file by ftp.

This is so a program running on a remote machine can get this ip address from the remote file and hence reach a machine on the lan side of the router. It can be considered a workaround for the absence of a free working dynamicdns service. Obviously, for appending to the remote file myip-upload.sh must have write access to that file.

Used without -a option it just returns the external ip and compares it but does not upload it if it has changed.

You need to create a conffile (see below) which can be specified using -c command line option or defaults to myip-upload.conf in the same directory as myip-upload.sh. This conffile contains the username and password for the ftp login with the address of the file on the ftp server to which the ip info is to be appended.

Usage

myip-upload.sh [Options] [Conffile]

Example

./myip-upload.sh -a -c ./myrouter.conf

Conffile

should contain definitions like this:

FTPUNMPWD="fred:fredsftppwd" (i.e. username:password)
FTPFILE=ftp://www.mywebsite.com/htdocs/my-iphistory.txt
HTTPFILE=https://www.mywebsite.com/my-iphistory.txt

Options

-a - actually upload and append ip to remote file by ftp
-c conffile - specify path & filename of conffile
-f - force upload even if HTTPFILE already seems correct
-d - debug mode (i.e. retain temporary file)
-h - show this help and exit
-l - show changelog and exit
-p - use active not passive ftp (i.e. '-P -' curl option)
-q - no text except showing the ip
-s - silent unless ip has changed

Dependencies

bash curl fold [g]awk grep sed stty telnet

License

Copyright © 2017 Dominic Raferd. Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Changelog

1.3 [23 May 2017] - follow redirects when retrieving HTTPFILE
1.2 [24 Nov 2016] - was using wrong default conf file
1.1 [07 Nov 2016] - use opendns.com to obtain ip and fallback to ipinfo.io
1.0 [02 Dec 2015] - abort if download fails
0.9 [24 Nov 2015] - add -s option
0.8 [28 Oct 2015] - adapted from huawei-ip-upload.sh
0.7 [04 Feb 2015] - make quiet mode less quiet if uploading, bugfix quiet mode
0.6 [22 Jan 2015] - check if uploaded file is already correct before uploading, add -f force mode, change conf file option to -c
0.5 [17 Jun 2014] - add verbose 2nd try and -p active ftp option
0.4 [23 May 2014] - minor text bugfixes
0.3 [12 Apr 2014] - improve help text, add -q option
0.2 [09 Apr 2014] - change to use telnet to obtain IP direct from Huawei HG533
0.1 [08 Apr 2014] - first version

Download myip-upload.sh

My Other Sites

My Programs

Here is a selection of some (other) programs I have written, most of which run from the command line (CLI), are freely available and can be obtained by clicking on the links. Dependencies are shown and while in most cases written for a conventional Linux server, they should run even on a Raspberry Pi, and many can run under Windows using Cygwin. Email me if you have problems or questions, or if you think I could help with a programming requirement.

Backup Utilities

Debian/Ubuntu kernel and LVM Utilities

Dellmont / Three / Giffgaff / Vodafone - VoIP and Mobile Phone Account Utilities

Miscellaneous Programs

Comments

No comments yet
*Name:
Email:
Hide my email
*Text:
 
Powered by Scriptsmill Comments Script