checkmyip/README.md

149 lines
5.1 KiB
Markdown
Raw Normal View History

# CheckMyIP - [myip.bsd.cafe](https://myip.bsd.cafe)
2024-05-09 15:23:06 +02:00
A Telnet, SSH, DNS and Simple HTTP Based Public IP Address Lookup Service
2017-09-02 03:54:28 +02:00
2018-05-09 19:24:14 +02:00
-----------------------------------------
2018-05-09 19:25:56 +02:00
### USAGE
2024-05-09 15:23:06 +02:00
#### DNS
- **DNS TXT Record**:
- Retrieve your IP via a DNS TXT record: `dig +short myip.bsd.cafe TXT @myip.bsd.cafe`
#### 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 username 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`
2024-06-13 22:13:28 +02:00
For HTTP (CURL and WGET above), use `myip.bsd.cafe/raw` to get only the email address. This also works for the HTTP IPv4 and IPv6 addresses.
2017-09-03 21:49:34 +02:00
2017-09-02 08:52:14 +02:00
-----------------------------------------
### VERSION ###
2020-04-29 17:40:01 +02:00
The version of CheckMyIP documented here is: **v1.3.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 ###
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 *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.
2017-09-02 03:54:28 +02:00
2017-09-02 08:52:14 +02:00
-----------------------------------------
### 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`).
2017-09-02 03:54:28 +02:00
You can also browse to the HTTP version of the service at [myip.bsd.cafe](https://myip.bsd.cafe/) which will return a JSON reply with your IP information.
2017-09-03 02:14:42 +02:00
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.
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 myip.bsd.cafe). Below is an example of how you can use it.
2017-09-05 22:13:36 +02:00
```
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.
2017-09-02 03:54:28 +02:00
Install Dependencies (for example, on a FreeBSD jail)
2017-09-02 03:54:28 +02:00
```
2024-05-09 15:23:06 +02:00
pkg install python39 py39-gssapi py39-paramiko py39-dnspython
2017-09-02 03:54:28 +02:00
```
Clone Repo and install
2017-09-05 23:00:51 +02:00
```
git clone https://brew.bsd.cafe/BSDCafe/checkmyip
cp checkmyip/checkmyip.py /usr/local/bin
chmod a+rx /usr/local/bin/checkmyip.py
2017-09-05 23:00:51 +02:00
```
Create Service (`vi /usr/local/etc/rc.d/checkmyip`)
2017-09-02 07:08:29 +02:00
```
#!/bin/sh
# PROVIDE: checkmyip
# REQUIRE: DAEMON
# KEYWORD: shutdown
. /etc/rc.subr
2017-09-05 23:00:51 +02:00
name="checkmyip"
rcvar=checkmyip_enable
2017-09-02 03:54:28 +02:00
load_rc_config $name
2017-09-02 03:54:28 +02:00
: ${checkmyip_enable:=no}
: ${checkmyip_user:="nobody"}
2017-09-02 03:54:28 +02:00
pidfile="/var/run/${name}.pid"
command="/usr/local/bin/checkmyip.py"
command_interpreter="/usr/local/bin/python3.9"
command_args="&"
start_precmd="checkmyip_precmd"
2017-09-02 03:54:28 +02:00
checkmyip_precmd() {
install -o ${checkmyip_user} -g ${checkmyip_user} /dev/null ${pidfile}
}
run_rc_command "$1"
2020-04-29 17:40:01 +02:00
```
2017-09-02 03:54:28 +02:00
2017-09-02 08:52:14 +02:00
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
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 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](https://github.com/packetsar/checkmyip)
2017-09-02 08:52:14 +02:00
2022-11-13 19:09:53 +01:00
[logo]: /checkmyip_icon-100.gif
2024-05-09 15:23:06 +02:00
[whatismyip]: https://www.whatismyip.com/