Skip to content

DeepWaterExploration/DWEOS-wifi-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WiFi Detector - Ethernet Bridge Manager

An intelligent network management tool that automatically detects whether your ROV system is connected to a router or directly to a client device, and creates an Ethernet bridge when needed to allow for sharing of DWEOS's web server.

What This Project Does

This application monitors your Ethernet connection and automatically:

  1. Detects Router vs Client Connections: Intelligently determines if your Ethernet connection is to a router (with internet access) or to a client device (like a laptop needing internet)

  2. Automatic Bridge Creation: When connected to a client device, automatically creates a bridge interface (br0) to share your internet connection

  3. DHCP Server Management: Starts a DHCP server using dnsmasq to assign IP addresses to connected client devices

  4. Smart Switching: Automatically switches between normal operation (when connected to router) and bridge mode (when sharing connection with clients)

  5. Clean Shutdown: Properly cleans up bridge interfaces and DHCP services when stopped

Key Features

  • Zero Configuration: Runs automatically without manual intervention
  • Intelligent Detection: Uses multiple methods to verify router connectivity (IP config, gateway, DHCP)
  • Robust Bridge Management: Creates and manages Linux bridge interfaces with proper STP configuration
  • DHCP Integration: Provides IP addresses to connected clients automatically
  • System Integration: Works with NetworkManager and systemd-resolved
  • Graceful Cleanup: Properly removes bridge interfaces and restores network settings on exit

System Requirements

  • Linux system with NetworkManager
  • Python 3.8+
  • Root/sudo privileges (required for network interface management)
  • dnsmasq, net-tools package
  • D-Bus system bus access

Installation

1. Clone the Repository

git clone <repository-url>
cd wifi-detector

2. Install System Dependencies

# On Ubuntu/Debian:
sudo apt update
sudo apt install dnsmasq net-tools python3-venv python3-pip

# On Fedora/RHEL:
sudo dnf install dnsmasq net-tools python3-venv python3-pip

# On Arch Linux:
sudo pacman -S dnsmasq python python-pip

3. Set Up Python Environment

# Create virtual environment
python3 -m venv env

# Activate virtual environment
source env/bin/activate

# Install Python dependencies
pip install -r requirements.txt

4. Make Run Script Executable

chmod +x run_with_env.sh

Usage

Running the Application

Important: This application requires root privileges to manage network interfaces.

sudo ./run_with_env.sh

Technical Details

Network Configuration

When bridge mode is active:

  • Bridge Interface: br0
  • Bridge IP: 192.168.2.101/24
  • DHCP Range: 192.168.2.100 - 192.168.2.200
  • Lease Time: 24 hours

Architecture

  • NetworkManager Integration: Uses D-Bus to communicate with NetworkManager
  • Bridge Management: Creates Linux bridge interfaces using ip commands
  • DHCP Service: Uses dnsmasq for DHCP server functionality

Detection Logic

The application uses multiple checks to determine router connectivity:

  1. Valid IP configuration (non-link-local addresses)
  2. Presence of default gateway
  3. DHCP-assigned configuration
  4. DNS server availability

Dependencies

  • sdbus: D-Bus Python bindings*
  • sdbus-networkmanager: NetworkManager D-Bus interface*
  • APT
  • dnsmasq: DHCP/DNS server
  • iproute2: Network interface management tools (Usually installed by default)
  • net-tools: View network configurations

* installed from requirements.txt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published