Skip to content

fidpa/netgear-lm1200-sms-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Netgear LM1200 SMS Gateway

Release License: MIT CI Python Platform Netgear LM1200 Maintenance PRs Welcome

Automated SMS reception and forwarding for Netgear LM1200 4G LTE Modem β€” 2FA/OTP codes directly to Telegram.

⚑ Features

  • πŸ“± Automatic SMS polling (every 5 minutes via systemd timer)
  • πŸ“¨ Optional Telegram forwarding for 2FA/OTP codes
  • πŸ’Ύ Local JSON storage (monthly rotated files)
  • πŸ”„ State management (no duplicates, no lost messages)
  • πŸ”’ Hash-based deduplication (robust against ID resets)
  • 🐍 Python 3.10+ with async/await
  • πŸ”’ systemd security hardening
  • πŸ” Optional SMS Encryption (AES-256 via Fernet)
  • πŸ”„ Retry Logic (exponential backoff for transient errors)
  • πŸ₯ Health-Check Endpoint (monitoring integration)

🚨 Critical: Germany-Specific Setup

IMPORTANT: SMS reception requires specific modem configuration:

  1. βœ… Network Mode: "Auto" (NOT "LTE Only"!)
  2. βœ… SMS Alerts: Enabled in modem settings

Without these settings, SMS will NOT be received. See docs/TROUBLESHOOTING.md for details.

πŸš€ Quick Start

Prerequisites

  • Netgear LM1200 4G LTE Modem with active SIM card
  • Linux system with Python 3.10+ and systemd
  • jq command-line JSON processor (for SMS parsing)
  • (Optional) Telegram Bot Token for SMS forwarding

Install jq:

# Debian/Ubuntu
sudo apt install jq

# RHEL/Fedora
sudo dnf install jq

Installation

  1. Clone repository:

    git clone https://github.com/fidpa/netgear-lm1200-sms-gateway
    cd netgear-lm1200-sms-gateway
  2. Install dependencies:

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
  3. Configure modem (CRITICAL!):

    • Open modem web UI: http://192.168.0.201
    • Set Network Mode to "Auto" (Network β†’ LTE Settings β†’ Band Selection)
    • Enable SMS Alerts (Settings β†’ General β†’ Alerts β†’ "On")
  4. Create configuration:

    sudo mkdir -p /etc/netgear-sms-gateway
    sudo cp config/config.example.env /etc/netgear-sms-gateway/config.env
    sudo nano /etc/netgear-sms-gateway/config.env
  5. Install systemd units:

    sudo cp systemd/*.{service,timer} /etc/systemd/system/
    
    # IMPORTANT: Edit service file and replace YOUR_USERNAME with your actual username
    sudo nano /etc/systemd/system/netgear-sms-poller.service
    # Change: User=YOUR_USERNAME β†’ User=yourname
    # Change: Group=YOUR_USERNAME β†’ Group=yourname
    
    sudo systemctl daemon-reload
    sudo systemctl enable --now netgear-sms-poller.timer
  6. Create symlink (REQUIRED):

    sudo ln -sf "$(pwd)/src/netgear_sms_wrapper.sh" /usr/local/bin/netgear-sms-poller
  7. Test:

    # Send test SMS to modem SIM card
    # Wait 5 minutes or trigger manually:
    sudo systemctl start netgear-sms-poller.service
    
    # Check logs:
    journalctl -u netgear-sms-poller.service -n 50

πŸ“– Documentation

πŸ”§ Configuration

Minimal (SMS Storage Only)

# /etc/netgear-sms-gateway/config.env
NETGEAR_IP=192.168.0.201
NETGEAR_ADMIN_PASSWORD=your_admin_password
SMS_STATE_DIR=/var/lib/netgear-sms-gateway

Optional (With Telegram Forwarding)

TELEGRAM_BOT_TOKEN=123456789:ABC...
TELEGRAM_CHAT_ID=12345678
TELEGRAM_PREFIX="[SMS Gateway]"
RATE_LIMIT_SECONDS=300

Advanced Configuration

Debug Logging

LOG_LEVEL=DEBUG  # Shows detailed hash checks, ID comparisons

SMS Encryption (Optional)

Requires: pip install cryptography>=42.0.0

SMS_ENCRYPTION_ENABLED=true
SMS_ENCRYPTION_KEY_FILE=/etc/netgear-sms-gateway/.encryption.key

Generate key: ./src/netgear_sms_poller.py generate-key

See docs/ENCRYPTION.md for full guide.

Note: Gateway works without encryption - install only if you need this feature.

Health Check

./src/netgear_sms_poller.py health
# Returns: 0 (healthy), 1 (degraded), 2 (down)

See docs/MONITORING.md for integration examples.

πŸ›‘οΈ Security

  • Credentials stored in /etc/netgear-sms-gateway/config.env (chmod 600)
  • systemd sandboxing: ProtectSystem=strict, PrivateTmp=yes
  • SMS content stored in /var/lib/netgear-sms-gateway/ (restricted access)

For vulnerability reporting and security best practices, see SECURITY.md.

πŸ“Š Use Cases

  • βœ… 2FA/OTP code reception (banking, services)
  • βœ… Automated SMS backup/archival
  • βœ… SMS-to-Telegram bridge for mobile access
  • βœ… Home automation SMS triggers

🀝 Contributing

Contributions welcome! Please see CONTRIBUTING.md for guidelines.

πŸ“œ License

MIT License - see LICENSE file for details.

πŸ”— Related Projects

About

Automated SMS reception and forwarding for Netgear LM1200 4G LTE Modem

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors