Skip to content

About

Beginner Python network automation: a ping check script that tests loopback, LAN, internet, and DNS, plus a debugging log of errors I fixed along the way.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Python Network Automation (Learning Repo)

A beginner repo where I'm learning Python by building small network tools. Started October 2026. Everything here is written, run, and debugged by me on my own PC.

What pingcheck.py does

pingcheck.py pings a list of addresses and reports whether each one replied (UP) or not (DOWN). It checks four things:

Address What it tests
127.0.0.1 Loopback: my PC's own network software
192.168.1.1 My router: the local network (LAN)
8.8.8.8 A raw internet IP: can traffic leave my network?
google.com A name: does DNS translate it to a number?

Reading the results in order shows where a connection breaks: my PC, my local network, or the internet. If the raw IP works but the name fails, that points to a DNS problem. Computers route traffic with numbers (four octets, like 8.8.8.8), and DNS is the translator that turns human-friendly names into those numbers.

I also keep a known-bad address (10.255.255.1) as a control during testing. When it correctly reports DOWN, I know the script can actually detect a failure.

How it works

  • subprocess.run(["ping", "-n", "1", ip]) runs the Windows ping command once per address.
  • result.returncode == 0 means the device replied. Any other value means it didn't.
  • A for loop repeats the check for every address in the devices list.

Run it

python pingcheck.py

Expected output on a healthy network:

127.0.0.1 is UP
192.168.1.1 is UP
8.8.8.8 is UP
google.com is UP

Debugging log

Real coding is mostly fixing broken code, so I practiced on purpose. The files in debugging-log/ are broken scripts I fixed by reading the error messages. Each challenge has the original broken file and the fixed version next to it.

Files Errors What it taught me
broken.py / broken_fixed.py Missing bracket, missing colon, missing indent Python uses brackets, colons, and indentation to know what belongs where. Quotes mean plain text; no quotes means a variable.
broken2.py / broken2_fixed.py IndentationError, then three TabErrors, plus = vs == Tabs and spaces look the same but Python treats them differently, so use spaces only. = stores a value; == asks a question.

Screenshots

First successful run First run
Debugging broken2.py (error to fix) Debugging errors
Four-address check, all UP Four address check
Final script Script code

Known limits

  • The script prints DOWN for any failure, so it can't say why something failed.
  • Ping can't tell whether my IP came from DHCP or was set manually. That needs ipconfig /all.

Next steps

  • Add a counter: 2 of 4 devices are UP
  • Test a fake name (notarealsite12345.com) to see what a DNS-style failure looks like
  • Read the device list from a text file instead of typing it in the code
  • Move from Notepad to VS Code

About

Beginner Python network automation: a ping check script that tests loopback, LAN, internet, and DNS, plus a debugging log of errors I fixed along the way.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages