Skip to content

Instantly share code, notes, and snippets.

@irgendwr
Created September 18, 2021 03:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irgendwr/13da1a02e31651bda769287d55b88d0d to your computer and use it in GitHub Desktop.
Save irgendwr/13da1a02e31651bda769287d55b88d0d to your computer and use it in GitHub Desktop.
This script lists all devices known to a FritzBox router
#!/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