Created
September 18, 2021 03:04
-
-
Save irgendwr/13da1a02e31651bda769287d55b88d0d to your computer and use it in GitHub Desktop.
This script lists all devices known to a FritzBox router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# This script lists all devices known to a FritzBox router. | |
# pip install fritzconnection | |
# Change this: | |
ADDRESS = '192.168.178.1' | |
USER = 'YOUR USER HERE' | |
PASS = 'YOUR PASSWORD HERE' | |
from fritzconnection import FritzConnection | |
from fritzconnection.lib.fritzhosts import FritzHosts | |
fc = FritzConnection(address=ADDRESS, user=USER, password=PASS) | |
hosts = FritzHosts(fc) | |
hostsInfo = hosts.get_hosts_info() | |
listformat = "{:<15} {:<17} {:<5} {:<20}" | |
print(listformat.format("IP", "MAC", "State", "Hostname")) | |
for host in hostsInfo: | |
print(listformat.format(host['ip'], host['mac'], "ON" if host['status'] else "OFF", host['name'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment