Get WAN IP Telegram Bot - is a simple utility that allows you to retrieve the WAN IP of your server in order to connect via SSH or for other purposes.
This is useful when your router has a direct Internet connection (not through another local network), but you don’t have a static IP and you don’t have physical access to your server or its LAN to check the current WAN IP.
Make sure you have the following installed:
bashgitpython>= 3.11- Python module
venv
Clone the repository:
git clone https://github.com/Klipar/GetWANIPTelegramBot.gitGo to the project directory:
cd GetWANIPTelegramBotGenerate configs with the script generateConfig.sh:
bash generateConfig.shEdit the configuration file config/config.json using nano or any other text editor:
nano config/config.jsonYou need to configure the following parameters:
- "API bot token" - your bot’s token. You can obtain it from Telegram bot @BotFather.
- "registered users" - list of Telegram User IDs that will have access to the bot. You can get your ID using @userinfobot, just by typing
/start. - "synthesize direct ssh connection command" - whether to generate a ready-to-use SSH connection command. If set to
true, the following fields must be specified:- "server login" - the server’s login username (used in the generated SSH command).
- "server ssh port" - the port forwarded from your router to the server (or the server’s own port if it is directly on the Internet).
⚠️ Note: the configuration file is only read at program startup. Changes will take effect only after restarting the bot.
If your Linux system uses systemd, you can install dependencies and create the service with:
bash setupAndStart.shIf systemd is not available, do it manually:
python3 -m venv .venv
source ".venv/bin/activate"
pip install -r requirements.txtRun the bot with:
.venv/bin/python main.pyThen you can add this command to autostart manually in your system.
You can also run the bot with Docker and docker-compose.
From the project directory, run:
docker-compose upThe bot will start, and you can use the same command to launch it later.
To stop and remove the service, run:
bash stopAndDeleteService.sh
⚠️ This script does not delete the project directory or its files, it only stops and removes the service.

