A Telnet, SSH, DNS and Web Based Public IP Address Lookup Service for BSD Cafe
Find a file
stefano 795c04e6df Updated README.md for BSD Cafe Fork
Signed-off-by: stefano <stefano@dragas.it>
2024-05-09 13:11:35 +02:00
checkmyip.py Changed to Ubuntu and updated for Py3 2020-04-29 08:40:01 -07:00
checkmyip_icon-100.gif Add files via upload 2022-11-13 10:09:26 -08:00
LICENSE Initial commit 2017-09-01 01:49:34 -07:00
README.md Updated README.md for BSD Cafe Fork 2024-05-09 13:11:35 +02:00

CheckMyIP - myip.bsd.cafe

A Telnet, SSH and Simple HTTP Based Public IP Address Lookup Service


USAGE

  • TELNET:
    • Default: telnet myip.bsd.cafe
    • IPv4: telnet myip4.bsd.cafe
    • IPv6: telnet myip6.bsd.cafe
  • SSH:
    • Default: ssh myip.bsd.cafe
    • IPv4: ssh myip4.bsd.cafe
    • IPv6: ssh myip6.bsd.cafe
    • Your SSH client may require you to enter a username. You can use anything you want (ssh -l imrootbitch myip.bsd.cafe)
  • CURL:
    • Default: curl -L myip.bsd.cafe
    • IPv4: curl -L myip4.bsd.cafe
    • IPv6: curl -L myip6.bsd.cafe
  • WGET:
    • Default: wget -qO- myip.bsd.cafe
    • IPv4: wget -qO- myip4.bsd.cafe
    • IPv6: wget -qO- myip6.bsd.cafe

VERSION

The version of CheckMyIP documented here is: v1.3.0


TABLE OF CONTENTS

  1. What is CheckMyIP
  2. How to Use
  3. Using the API
  4. Install Process
  5. 1.0.0 TO 1.1.0 Updates
  6. Contributing

WHAT IS CHECKMYIP

Everybody has used a service like 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 *BSD or 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 myip.bsd.cafe public services were created with this in mind.


HOW TO USE

Using the public myip.bsd.cafe service is pretty easy: simply connect to them with a terminal client. You can use a telnet client with TCP port 23 (telnet myip.bsd.cafe), a SSH client with TCP port 22 (ssh myip.bsd.cafe), or CURL (curl -L myip.bsd.cafe). 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 myip.bsd.cafe).

You can also browse to the HTTP version of the service at myip.bsd.cafe 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 section for information on how to leverage the API.


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 myip.bsd.cafe). 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"])

INSTALL PROCESS

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.

Install Dependencies (for example, on a FreeBSD jail)

pkg install python39 py39-gssapi py39-paramiko

Clone Repo and install

git clone https://brew.bsd.cafe/BSDCafe/checkmyip
cp checkmyip/checkmyip.py /usr/local/bin
chmod a+rx /usr/local/bin/checkmyip.py

Create Service (vi /usr/local/etc/rc.d/checkmyip)

#!/bin/sh

# PROVIDE: checkmyip
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr

name="checkmyip"
rcvar=checkmyip_enable

load_rc_config $name

: ${checkmyip_enable:=no}
: ${checkmyip_user:="nobody"}

pidfile="/var/run/${name}.pid"
command="/usr/local/bin/checkmyip.py"
command_interpreter="/usr/local/bin/python3.9"
command_args="&"
start_precmd="checkmyip_precmd"

checkmyip_precmd() {
    install -o ${checkmyip_user} -g ${checkmyip_user} /dev/null ${pidfile}
}

run_rc_command "$1"

Finish and Start Up Service

chmod a+rx /usr/local/etc/rc.d/checkmyip
mkdir /var/log/checkmyip
chown nobody:nobody /var/log/checkmyip

service checkmyip enable
service checkmyip start

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.

UPDATES IN V1.1.0 --> V1.3.0

  • README updated for install on Ubuntu instead of CentOS
  • Small tweaks to support Python3

CONTRIBUTING

If you would like to help out by contributing code or reporting issues, please do!

Visit the BSD Cafe Brew page (https://brew.bsd.cafe/BSDCafe/checkmyip) and either report an issue or fork the project, commit some changes, and submit a pull request.

Original code by John W Kerns