This Bash script fetches network details (WiFi SSID, interface, IP address) and sends them to a Discord webhook. It also uploads a detailed log file and is configured to run at startup using systemd
.
- Collects network details using
ifconfig
andiwconfig
. - Sends details as a Discord embed and uploads a log file.
- Runs automatically at system startup.
Install required tools:
sudo apt update
sudo apt install net-tools wireless-tools curl
- Place the
networkinfo.sh
script anywhere (e.g./var/www/html/
for my convenience with other automations) and make it executablesudo chmod +x /var/www/html/networkinfo.sh
- Replace the webhook URL in the script:
webhook_url="https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"
- Create a service file:
sudo nano /etc/systemd/system/networkinfo.service
- Add:
[Unit] Description=Run networkinfo.sh at startup After=network-online.target Requires=network-online.target [Service] ExecStart=/var/www/html/networkinfo.sh Restart=on-failure [Install] WantedBy=multi-user.target
- Enable the service:
sudo systemctl daemon-reload sudo systemctl enable networkinfo.service sudo systemctl start networkinfo.service
Discord Embed:
- Connected WiFi: ExampleSSID
- WiFi Interface: wlan0
- IP Address: 192.168.0.101
Uploaded File (network_info.txt
):
ifconfig output:
[Full output of ifconfig]
iwconfig output:
[Full output of iwconfig]
Connected WiFi: ExampleSSID
WiFi Interface: wlan0
IP Address: 192.168.0.101
- Permission Errors: Ensure script has write permissions:
sudo chmod +w /var/www/html/
- Service Issues: Check logs:
sudo journalctl -u networkinfo.service
Happy coding !