Skip to content

This Bash script fetches network details and sends them to a Discord webhook.

Notifications You must be signed in to change notification settings

navnee1h/network-info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Network Information Script

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.


Features

  • Collects network details using ifconfig and iwconfig.
  • Sends details as a Discord embed and uploads a log file.
  • Runs automatically at system startup.

Setup

Dependencies

Install required tools:

sudo apt update
sudo apt install net-tools wireless-tools curl

Script Setup

  1. Place the networkinfo.sh script anywhere (e.g. /var/www/html/ for my convenience with other automations) and make it executable
    sudo chmod +x /var/www/html/networkinfo.sh
  2. Replace the webhook URL in the script:
    webhook_url="https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"

Configure systemd

  1. Create a service file:
    sudo nano /etc/systemd/system/networkinfo.service
  2. 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
  3. Enable the service:
    sudo systemctl daemon-reload
    sudo systemctl enable networkinfo.service
    sudo systemctl start networkinfo.service

Example Output

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

Troubleshooting

  • Permission Errors: Ensure script has write permissions:
    sudo chmod +w /var/www/html/
  • Service Issues: Check logs:
    sudo journalctl -u networkinfo.service

Happy coding !

About

This Bash script fetches network details and sends them to a Discord webhook.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages