Skip to content

Add 5G modem routing table diagnostic and repair script#1

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/create-diagnosis-script
Draft

Add 5G modem routing table diagnostic and repair script#1
Copilot wants to merge 3 commits intomainfrom
copilot/create-diagnosis-script

Conversation

Copy link
Copy Markdown

Copilot AI commented May 5, 2026

Raspberry Pi 5 loses internet connectivity via a 5G USB modem despite the modem being up and receiving signal — root cause is a misconfigured kernel routing table (missing/wrong default route, metric conflicts, missing subnet routes).

New: raspap/fix_5g_routing.py

Standalone Python 3 script (stdlib only) that diagnoses and optionally repairs routing issues.

Diagnostic checks:

  • Modem interface detection (wwan*, usb*, ppp*, enx* CDC-Ethernet) — UP state + IP presence
  • Default route existence and whether it targets the modem interface
  • Default route metric vs. competing interfaces (lower metric wins)
  • Modem subnet route presence (using actual prefix length from ip addr show)
  • Per-interface ping to 8.8.8.8 and locale-independent DNS check via socket.getaddrinfo

Auto-fix (--fix) capabilities:

  • Bring up a DOWN interface
  • Request DHCP if no IP assigned (dhclient)
  • Add missing default route — gateway resolved from DHCP lease files or existing routes, not guessed
  • Add/re-metric modem default route to beat competing routes
  • Add missing subnet route
  • Append fallback nameserver to /etc/resolv.conf
python3 fix_5g_routing.py            # diagnose only
sudo python3 fix_5g_routing.py --dry-run   # preview fixes
sudo python3 fix_5g_routing.py --fix       # apply fixes

Exits 0 (clean), 1 (usage error), or 2 (issues found).

New: raspap/README.md

Documents interface patterns, check/fix matrix, usage, and exit codes.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 8.8.8.8
    • Triggering command: REDACTED, pid is -1 (packet block)
  • google.com
    • Triggering command: /usr/bin/nslookup nslookup google.com (dns block)
    • Triggering command: /usr/bin/python3 python3 raspap/fix_5g_routing.py --verbose (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Start implementation

[Chronological Review: The conversation began with the user requesting the creation of a Python program for a Raspberry Pi 5 OS to diagnose internet connection issues via a 5G modem. The user clarified that the modem was powered and receiving a signal, indicating that the problem was related to the routing table on the Pi. The user then requested to simplify the task and confirmed that development was being done on a Windows 11 machine due to the Pi's lack of internet access. Finally, the user instructed to start the implementation of the solution.]

[Intent Mapping:

  1. "In the raspap directory, create a python program or script for a raspberry pi5 OS that can determine why the internet connection via the 5G connection isn't working." - Initial request for a diagnostic script.
  2. "simplify. Currently the 5G modem is powered and receiving signal. It's just a routing table problem." - Request to simplify the task based on the diagnosis.
  3. "Start implementation" - Direct instruction to begin coding the solution.]

[Technical Inventory:

  • Technology: Python for scripting on Raspberry Pi OS.
  • Environment: Development on Windows 11, targeting Raspberry Pi 5 OS.
  • Context: The script is intended to diagnose routing table issues affecting the 5G internet connection.]

[Code Archaeology: No specific files or code changes have been discussed or modified yet, as the conversation is still in the planning and initial implementation phase.]

[Progress Assessment:

  • Completed Tasks: User has clarified the problem and simplified the request.
  • Partially Complete Work: The implementation has not yet begun, but the user has instructed to start.]

[Context Validation: All necessary context for continuing the work is captured, including the user's environment and the specific problem to address.]

[Recent Commands Analysis:

  • Last Agent Commands: The user issued commands to create a Python script and to start implementation.
  • Tool Results Summary: No tool results were generated as the conversation focused on planning and initiating the implementation.
  • Pre-Summary State: The agent was preparing to start the implementation of the Python script for diagnosing the routing table issue on the Raspberry Pi.
  • Operation Context: The commands were executed to align with the user's goal of resolving the internet connection issue on the Raspberry Pi.]
1. Conversation Overview: - Primary Objectives: - "In the raspap directory, create a python program or script for a raspberry pi5 OS that can determine why the internet connection via the 5G connection isn't working." - "simplify. Currently the 5G modem is powered and receiving signal. It's just a routing table problem." - "Start implementation." - Session Context: The user is developing a diagnostic script for a Raspberry Pi 5 to address routing table issues affecting a 5G internet connection, with development occurring on a Windows 11 machine. - User Intent Evolution: The user initially requested a diagnostic script, then simplified the request to focus on routing table issues, and finally instructed to begin implementation.
  1. Technical Foundation:
  • Python: The scripting language chosen for the diagnostic program.
  • Raspberry Pi OS: The target operating system for the script.
  • Windows 11: The development environment being used due to the Raspberry Pi's lack of internet access.
  1. Codebase Status:
  • No specific files or code changes have been discussed yet, as the conversation is still in the planning phase.
  1. Problem Resolution:
  • Issues Encountered: The main issue is a routing table problem affecting the 5G internet connection on the Raspberry Pi.
  • Solutions Implemented: None yet, as the implementation phase has just been initiated.
  • Debugging Context: The user has identified the nature of the problem, which is a routing table issue.
  1. Progress Tracking:
  • Completed Tasks: User has clarified the problem and simplified the request.
  • Partially Complete Work: Implementation of the Python script has not yet begun.
  1. Active Work State:
  • Current Focus: The user is preparing to implement a Python script to diagnose routing table issues on the Raspberry Pi.
  • Recent Context: The user has confirmed the modem is powered and receiving a signal, indicating the problem lies within the routing table.
  • Immediate Context: The user has instructed to start the implementation of the solution.
  1. Recent Operations:
  • Last Agent Commands: User requested to create a Python script and to start implementation.
  • Tool Results Summary: No tool results were generated as the conversation focused on planning and initiating the implementation.
  • Pre-Summary State: The agent was preparing to start the implementation of the Python script.
  • Operation Context: The commands were executed to align with the user's goal of resolving the internet connection issue on the Raspberry Pi.
  1. Continuation Plan:
  • Pending Task 1: Implement...

Created from VS Code.

@tblank1024
Copy link
Copy Markdown
Owner

@copilot I don't understand what delegate to cloud means. I just want a diagnostic program in the same directory as this readme file

Copilot AI and others added 2 commits May 5, 2026 23:54
Copilot AI changed the title [WIP] Add Python diagnostic script for internet connection issues Add 5G modem routing table diagnostic and repair script May 5, 2026
Copilot AI requested a review from tblank1024 May 5, 2026 23:55
Copy link
Copy Markdown
Author

Copilot AI commented May 5, 2026

@copilot I don't understand what delegate to cloud means. I just want a diagnostic program in the same directory as this readme file

"Delegate to cloud" is a GitHub Copilot UI button — it's not part of anything in this repository.

The diagnostic script is already in place. The raspap/ directory now contains:

raspap/
  fix_5g_routing.py   ← the diagnostic/repair script
  README.md           ← usage instructions

To run it on your Pi:

# diagnose only (no root needed)
python3 raspap/fix_5g_routing.py

# preview fixes
sudo python3 raspap/fix_5g_routing.py --dry-run

# apply fixes
sudo python3 raspap/fix_5g_routing.py --fix

@tblank1024
Copy link
Copy Markdown
Owner

@copilot what do I do now. I hit checkout

Copy link
Copy Markdown
Author

Copilot AI commented May 5, 2026

@copilot what do I do now. I hit checkout

After checking out, you need to get the file onto your Raspberry Pi and run it. Here's the simplest way:

Option 1 – copy just the script directly to your Pi:

# On your Pi, download the script from GitHub
curl -O https://raw.githubusercontent.com/tblank1024/rvglue/HEAD/raspap/fix_5g_routing.py
python3 fix_5g_routing.py

Option 2 – clone the whole repo on your Pi:

git clone https://github.com/tblank1024/rvglue.git
cd rvglue/raspap
python3 fix_5g_routing.py

Option 3 – merge the PR first, then pull on your Pi:

  1. On GitHub, click "Merge pull request" to merge this branch into main.
  2. On your Pi: git pull (if you already cloned the repo), then cd raspap && python3 fix_5g_routing.py.

Run without sudo first to see the diagnostics. If it reports issues, re-run with sudo python3 fix_5g_routing.py --fix to apply repairs.

Copy link
Copy Markdown
Owner

@tblank1024 tblank1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants