checkmyip/README.md

191 lines
5.7 KiB
Markdown
Raw Normal View History

2017-09-05 21:41:42 +02:00
# CheckMyIP (TelnetMyIP [![Twitter][twitter-logo]][twitter]) [![CheckMyIP][logo]][twitter]
2017-09-05 23:12:48 +02:00
A Telnet and SSH Based Public IP Address Lookup Service
2017-09-02 03:54:28 +02:00
2017-09-05 23:12:48 +02:00
Lookup your IP Address from a CLI with `telnet telnetmyip.com` or `ssh sshmyip.com`
2017-09-02 03:54:28 +02:00
2017-09-03 21:49:34 +02:00
2017-09-02 08:52:14 +02:00
-----------------------------------------
### VERSION ###
2018-02-13 23:59:01 +01:00
The version of CheckMyIP documented here is: **v1.1.0**
2017-09-02 03:54:28 +02:00
2017-09-02 08:52:14 +02:00
-----------------------------------------
### TABLE OF CONTENTS ###
1. [What is CheckMyIP](#what-is-checkmyip)
2. [How to Use](#how-to-use)
2017-09-05 22:13:36 +02:00
3. [Using the API](#using-the-api)
4. [Install Process](#install-process)
2018-02-13 23:59:01 +01:00
5. [1.0.0 TO 1.1.0 Updates](#updates-in-v100----v110)
6. [Contributing](#contributing)
2017-09-02 03:54:28 +02:00
2017-09-02 08:52:14 +02:00
-----------------------------------------
### WHAT IS CHECKMYIP ###
2017-09-05 22:13:36 +02:00
Everybody has used a service like [WhatIsMyIP.com](https://www.whatismyip.com/) before. If you are an IT engineer or even an amateur technology enthusiast, then you have probably had a reason to check to see your public IP address. This service works great when a browser is available, but at times it is not. We often find ourselves logged into a remote Linux machine or a network switch/router which has a command line and terminal clients (Telnet and SSH), but no browser. The CheckMyIP app and the **TelnetMyIP.com** and **SSHMyIP.com** public services were created with this in mind.
2017-09-02 03:54:28 +02:00
2017-09-02 08:52:14 +02:00
-----------------------------------------
### HOW TO USE ###
2017-09-03 02:14:42 +02:00
Using the public **TelnetMyIP.com** and **SSHMyIP.com** services is pretty easy: simply connect to them with a terminal client. You can use a telnet client with TCP port 23 (`telnet telnetmyip.com`), or a SSH client with TCP port 22 (`ssh sshmyip.com`). The SSH connection requires no authentication, but your SSH client may require you to enter a username, you can use anything you want as it gets ignored anyways(`ssh -limrootbitch telnetmyip.com`).
2017-09-02 03:54:28 +02:00
2017-09-03 02:14:42 +02:00
You can also browse to the HTTP version of the service at [TelnetMyIP.com](http://telnetmyip.com/) which will return a JSON reply with your IP information.
To enable the use of this service as a simple API, the response is formatted as a JSON document. See the [Using the API](#using-the-api) section for information on how to leverage the API.
**Note:** _You can also connect to_ `ipv4.telnetmyip.com` _or_ `ipv6.telnetmyip.com` _if you want to check a specific IP stack._
**Note:** _The DNS records for_ `telnetmyip.com` _and_ `sshmyip.com` _point to the same services._
2017-09-02 03:54:28 +02:00
2017-09-02 08:52:14 +02:00
2017-09-05 22:13:36 +02:00
-----------------------------------------
### USING THE API ###
The CheckMyIP code contains the `CheckMyIP_Client` class which is an API client example which can be used to query a CheckMyIP server (like telnetmyip.com). Below is an example of how you can use it.
```
from checkmyip import CheckMyIP_Client
client = CheckMyIP_Client()
ipdict = client.get()
print("\nMy IP is %s\n" % ipdict["ip"])
print("\nI used port number %s\n" % ipdict["port"])
```
2017-09-02 08:52:14 +02:00
-----------------------------------------
### INSTALL PROCESS ###
2017-09-02 09:06:31 +02:00
If you would rather set up your own private instance of CheckMyIP, then you can follow the below instructions to set it up for yourself.
Change Linux SSH Port to TCP 222 and reboot
2017-09-02 03:54:28 +02:00
```
sudo sed -i --follow-symlinks 's/#Port 22/Port 222/g' /etc/ssh/sshd_config
shutdown -r now
```
Install Dependencies
```
2017-09-05 23:00:51 +02:00
yum install git -y
2017-09-02 03:54:28 +02:00
yum install gcc -y
yum install libffi-devel -y
yum install openssl-devel -y
pip install python-gssapi
```
2017-09-05 23:00:51 +02:00
Clone Repo
```
git clone https://github.com/PackeTsar/checkmyip.git
```
2017-09-02 07:08:29 +02:00
Install Binary
```
2017-09-05 23:00:51 +02:00
cd checkmyip
2017-09-02 07:08:29 +02:00
cp checkmyip.py /bin/checkmyip
chmod 777 /bin/checkmyip
2017-09-02 03:54:28 +02:00
2017-09-02 07:08:29 +02:00
mkdir -p /etc/checkmyip/
```
2017-09-02 03:54:28 +02:00
2017-09-02 07:08:29 +02:00
Create Service (`vi /etc/init.d/checkmyip`)
```
#!/bin/bash
2017-09-02 08:52:14 +02:00
# checkmyip daemon
2017-09-02 07:08:29 +02:00
# chkconfig: 345 20 80
2017-09-02 08:52:14 +02:00
# description: CheckMyIP Daemon
# processname: checkmyip
2017-09-02 07:08:29 +02:00
DAEMON_PATH="/bin/"
2017-09-02 08:52:14 +02:00
DAEMON=checkmyip
2017-09-05 21:01:31 +02:00
STDOUTFILE=/etc/checkmyip/stdout.log
STDERR=/etc/checkmyip/stderr.log
2017-09-02 07:08:29 +02:00
2017-09-02 08:52:14 +02:00
NAME=CheckMyIP
DESC="CheckMyIP Daemon"
2017-09-02 07:08:29 +02:00
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
2017-09-05 21:01:31 +02:00
PID=`stdbuf -o0 $DAEMON >> $STDOUTFILE 2>>$STDERR & echo $!`
2017-09-02 07:08:29 +02:00
#echo "Saving PID" $PID " to " $PIDFILE
if [ -z $PID ]; then
printf "%s
" "Fail"
else
echo $PID > $PIDFILE
printf "%s
" "Ok"
fi
;;
status)
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
printf "%s
" "Process dead but pidfile exists"
else
echo "$DAEMON (pid $PID) is running..."
fi
else
printf "%s
" "$DAEMON is stopped"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=`cat $PIDFILE`
cd $DAEMON_PATH
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s
" "Ok"
rm -f $PIDFILE
else
printf "%s
" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac
```
2017-09-02 03:54:28 +02:00
2017-09-02 08:52:14 +02:00
Finish and Start Up Service
```
chmod 777 /etc/init.d/checkmyip
chkconfig checkmyip on
service checkmyip start
service checkmyip status
```
2018-02-13 23:59:01 +01:00
-----------------------------------------
### UPDATES IN V1.0.0 --> V1.1.0 ###
**NEW FEATURES:**
- Was seeing issues where SSH would be very slow to exchange. Likely related to log file sizes, so I change the logging function to turnover to new logging files every day.
2017-09-02 08:52:14 +02:00
-----------------------------------------
### CONTRIBUTING ###
If you would like to help out by contributing code or reporting issues, please do!
Visit the GitHub page (https://github.com/packetsar/checkmyip) and either report an issue or fork the project, commit some changes, and submit a pull request.
2017-09-05 21:46:54 +02:00
[twitter-logo]: http://www.packetsar.com/wp-content/uploads/twitter-logo-35.png
2017-09-03 21:49:34 +02:00
[twitter]: https://twitter.com/TelnetMyIP
2017-09-02 08:52:14 +02:00
[logo]: http://www.packetsar.com/wp-content/uploads/checkmyip_icon-100.gif
[whatismyip]: https://www.whatismyip.com/