Updated README.md for BSD Cafe Fork

Signed-off-by: stefano <stefano@dragas.it>
This commit is contained in:
Stefano Marinelli 2024-05-09 13:11:35 +02:00
parent 24f9d0e5de
commit 795c04e6df

115
README.md
View file

@ -1,14 +1,29 @@
# CheckMyIP (TelnetMyIP.com) ![CheckMyIP][logo] # CheckMyIP - [myip.bsd.cafe](https://myip.bsd.cafe)
A Telnet, SSH and Simple HTTP Based Public IP Address Lookup Service A Telnet, SSH and Simple HTTP Based Public IP Address Lookup Service
----------------------------------------- -----------------------------------------
### USAGE ### USAGE
- TELNET: `telnet telnetmyip.com`
- SSH: `ssh sshmyip.com` - **TELNET**:
- Your SSH client may require you to enter a username. You can use anything you want (`ssh -limrootbitch telnetmyip.com`) - Default: `telnet myip.bsd.cafe`
- CURL: `curl telnetmyip.com` - IPv4: `telnet myip4.bsd.cafe`
- WGET: `wget -qO- telnetmyip.com` - 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 ### ### VERSION ###
@ -26,25 +41,20 @@ The version of CheckMyIP documented here is: **v1.3.0**
----------------------------------------- -----------------------------------------
### WHAT IS CHECKMYIP ### ### 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 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. 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.
----------------------------------------- -----------------------------------------
### HOW TO USE ### ### HOW TO USE ###
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`), a SSH client with TCP port 22 (`ssh sshmyip.com`), or CURL (`curl telnetmyip.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`). 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 [TelnetMyIP.com](http://telnetmyip.com/) which will return a JSON reply with your IP information. 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.
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. 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._
----------------------------------------- -----------------------------------------
### USING 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 telnetmyip.com). Below is an example of how you can use it. 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 from checkmyip import CheckMyIP_Client
@ -60,54 +70,61 @@ print("\nI used port number %s\n" % ipdict["port"])
### INSTALL PROCESS ### ### 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. 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
```
sudo sed -i --follow-symlinks 's/#Port 22/Port 222/g' /etc/ssh/sshd_config
shutdown -r now Install Dependencies (for example, on a FreeBSD jail)
```
pkg install python39 py39-gssapi py39-paramiko
``` ```
Install Dependencies Clone Repo and install
``` ```
sudo apt install python3-pip git clone https://brew.bsd.cafe/BSDCafe/checkmyip
sudo -H pip3 install paramiko cp checkmyip/checkmyip.py /usr/local/bin
sudo apt install python3-gssapi chmod a+rx /usr/local/bin/checkmyip.py
``` ```
Clone Repo Create Service (`vi /usr/local/etc/rc.d/checkmyip`)
```
git clone https://github.com/PackeTsar/checkmyip.git
``` ```
#!/bin/sh
Create Service (`sudo nano /etc/systemd/system/checkmyip.service`) # PROVIDE: checkmyip
``` # REQUIRE: DAEMON
[Unit] # KEYWORD: shutdown
Description=CheckMyIP Service
After=network-online.target
Wants=network-online.target
[Service] . /etc/rc.subr
Type=simple
PIDFile=/var/tmp/checkmyip.pid name="checkmyip"
WorkingDirectory=/home/ubuntu/checkmyip rcvar=checkmyip_enable
ExecStart=/usr/bin/python3 checkmyip.py load_rc_config $name
Restart=on-failure : ${checkmyip_enable:=no}
RestartSec=30 : ${checkmyip_user:="nobody"}
PrivateTmp=true
[Install] pidfile="/var/run/${name}.pid"
WantedBy=multi-user.target 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 Finish and Start Up Service
``` ```
sudo systemctl daemon-reload chmod a+rx /usr/local/etc/rc.d/checkmyip
sudo systemctl enable checkmyip mkdir /var/log/checkmyip
sudo systemctl start checkmyip chown nobody:nobody /var/log/checkmyip
sudo systemctl status checkmyip
service checkmyip enable
service checkmyip start
``` ```
@ -130,9 +147,9 @@ sudo systemctl status checkmyip
### CONTRIBUTING ### ### CONTRIBUTING ###
If you would like to help out by contributing code or reporting issues, please do! 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. 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)
[twitter-logo]: http://www.packetsar.com/wp-content/uploads/twitter-logo-35.png
[twitter]: https://twitter.com/TelnetMyIP
[logo]: /checkmyip_icon-100.gif [logo]: /checkmyip_icon-100.gif
[whatismyip]: https://www.whatismyip.com/ [whatismyip]: https://www.whatismyip.com/