A simple Discord bot that helps you keep track of your Raspberry Pi or Linux-based systems on home networks that use DHCP.
Because DHCP may assign a different IP address on each boot, this bot sends the current IP to your Discord account automatically. This makes it much easier to find and connect to the Pi again, especially when Avahi / raspberrypi.local is not working reliably.
- Sends your Raspberry Pi IP address on startup
- Makes it easier to find the Pi after DHCP assigns a new IP
- Supports
shutdown,restart,system info,disk usage,speedtest,update, andrestart avahicommands - Uses a virtual environment
- Runs automatically on boot with
systemd
- The Raspberry Pi boots
- systemd automatically starts the bot
- The bot retrieves the current local IP
- The IP is sent to your Discord DM
- You can then control the Pi remotely via commands
- Raspberry Pi OS or another Linux system
- Python 3
- Discord bot token
- Discord user ID
sudoaccess for the commands you want to run
git clone https://github.com/TiagoR07/Notify-IP.git
cd Notify-IPpython3 -m venv venv
source venv/bin/activatepython -m pip install -r requirements.txtCreate a .env file:
nano .envUpdate the fields with your actual Discord credentials:
DISCORD_TOKEN=your_bot_token_here
DISCORD_USER_ID=your_user_id_heresource venv/bin/activate
python main.pyThe project includes a setup.sh script to automate the creation of the systemd service. Before running, ensure the paths inside setup.sh match your username.
chmod +x setup.shOpen the script and ensure the following variables match your system:
PROJECT_DIR="$(pwd)"
SCRIPT_PATH="$PROJECT_DIR/main.py"
VENV_PATH="$PROJECT_DIR/venv"
Make sure:
SCRIPT_PATHpoints to your actual script locationPYTHON_PATHmatches your Python virtual environment path
nano setup.sh./setup.shsudo nano /etc/systemd/system/ip-discord.serviceIf you need to quickly stop or start the bot, use the included toggle script:
chmod +x toggle.sh./toggle.shCreate a dedicated sudoers file:
sudo visudo -f /etc/sudoers.d/ip-discordAdd these lines, replacing tiago with your actual user:
tiago ALL=(ALL) NOPASSWD: /sbin/shutdown
tiago ALL=(ALL) NOPASSWD: /sbin/reboot
tiago ALL=(ALL) NOPASSWD: /usr/bin/apt update, /usr/bin/apt upgrade *, /usr/bin/apt install *
tiago ALL=(ALL) NOPASSWD: /bin/systemctl restart avahi-daemon, /bin/systemctl enable avahi-daemon
Warning
This project provides remote system control capabilities via Discord.
- System shutdown / reboot
- Package management (apt update/upgrade/install)
- Service control (systemctl)
- System monitoring
- Access restricted to a single trusted Discord user (
DISCORD_USER_ID) - Bot token stored securely in
.env - Must be used only in a private/home network environment
Improper configuration may result in unauthorized remote control of the system.
- Do not expose your Discord bot token publicly.
- This project is especially useful on home networks that use DHCP, where the Raspberry Pi may get a different IP after each reboot.
- Avahi /
raspberrypi.localcan be convenient, but it does not always work reliably, so the Discord notification provides a practical fallback. - Some commands require a Linux based OS because they depend on system tools like systemctl, apt, and /sys hardware interfaces.
Notify-IP is released under the MIT License.
Feel free to use, modify, and distribute the software as you wish! If you find this tool useful, I’d be truly grateful if you could keep a reference to the original author. It helps support my work and lets others find the project.
Contributions are always welcome! 🚀