Skip to content

Rishi-Bhati/intermux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 InterMux

Advanced Network Interface Management for Linux

Python Version License Platform Root Required

Bind applications to specific network interfaces with ease

Features β€’ Installation β€’ Usage β€’ Architecture β€’ Contributing


πŸ“‹ Overview

InterMux is a powerful Linux utility that enables you to bind applications to specific network interfaces. Whether you need to route your browser through Wi-Fi while keeping your development server on Ethernet, or isolate applications for security testing, InterMux makes it simple.

🎯 Use Cases

  • Multi-WAN Management: Route different applications through different internet connections β€” boost speed, balance load, or bypass network-specific restrictions
  • Network Testing: Test applications on specific network interfaces
  • Security Isolation: Isolate applications in separate network namespaces
  • Bandwidth Management: Control which apps use which network connections
  • Development: Test network-dependent applications across different interfaces

πŸ’‘ Why I Made It

I was downloading a large file via torrent, and while waiting, I opened YouTube to pass the time. But the videos were stuck on low quality, buffering like crazy β€” even though my connection showed 300 Mbps.

Turns out, the torrent was consuming all the bandwidth, and YouTube was left starving. That’s when I had the idea: β€œWhat if I could assign different apps to different networks?”

After some research, I found that while Linux supports advanced networking, there wasn’t a simple tool to do what I needed β€” especially one that was GUI-friendly and straightforward.

So I built InterMux: A utility that lets me bind any app to a specific interface with ease β€” no messy configs, no guesswork, just full control.

✨ Features

πŸ–₯️ Core Features

  • πŸ” Auto-detection of all network interfaces
  • πŸ›£οΈ Custom routing tables per interface
  • πŸ”’ Network namespace isolation
  • πŸ“Š Real-time interface monitoring
  • πŸŽ›οΈ Both CLI and GUI interfaces

🌟 Interface Support

  • πŸ“Ά Wi-Fi (wlan*, wl*)
  • πŸ”Œ Ethernet (eth*, en*)
  • πŸ“± USB Tethering
  • πŸ”΅ Bluetooth Tethering
  • 🌐 Virtual Interfaces

πŸš€ Installation

Prerequisites

# Required system packages
sudo apt update
sudo apt install -y python3 python3-pip python3-tk iproute2 iptables

# Python Virtual environment
python -m venv venv
source venv/bin/activate

# Python dependencies in the venv
pip3 install -r requirements.txt
  • Note for Ubuntu 24.04+ users: Some Python modules (like brotli) may require system-level installation.
# If pip fails
sudo apt install python3-brotli

Clone and Setup

# Clone the repository
git clone https://github.com/yourusername/intermux.git
cd intermux


# Python Virtual environment
python -m venv venv
source venv/bin/activate

# Install Python dependencies
pip3 install -r requirements.txt

# Make scripts executable (optional)
chmod +x core/router.py

🧩 Packeges Required (If everything above fails)

  • You can explicitly install these packeges, if all the above given installation steps fails.
Brotli==1.1.0
click==8.2.1
markdown2==2.5.3
MarkupSafe==3.0.2
minijinja==2.11.0
page==0.3
PyYAML==6.0.2
tk==0.1.0

πŸ“– Usage

🎨 GUI Mode (Recommended)

Launch the modern graphical interface:

# The GUI will request root privileges via pkexec
python3 gui/app.py
GUI Features
  • Interface Selection: Dropdown menu with all active interfaces
  • Application Binding: Easy path entry and interface assignment
  • Visual Management: See all created bindings at a glance
  • One-Click Actions: Assign, refresh, and clear operations

πŸ’» CLI Mode

The CLI provides full functionality for managing network interface bindings from the command line:

1. List Active Interfaces

sudo python3 cli.py list

Output example:

--- Active Network Interfaces ---

Interface: wlan0
  Status: UP
  Type: Wi-Fi
  IP Addresses: 192.168.1.100/24, fe80::1234:5678:9abc:def0/64
  Gateways: 192.168.1.1

Interface: enp7s0f4u1
  Status: UP
  Type: Ethernet
  IP Addresses: 10.252.21.95/24
  Gateways: 10.252.21.177

2. Assign Application to Interface

sudo python3 cli.py assign --app /usr/lib/firefox/firefox --iface wlan0

This command:

  1. Creates a network namespace for the interface
  2. Sets up virtual ethernet pairs (veth0/veth1)
  3. Configures routing within the namespace
  4. Launches the application in the isolated environment

3. Clear All Assigned Paths

sudo python3 cli.py clear

Removes all custom routing tables and clears assigned paths.

4. Reset Everything

sudo python3 cli.py reset

Completely resets the system by:

  • Removing all veth interfaces
  • Deleting network namespaces
  • Clearing custom routing tables
  • Restoring system to defaults

CLI Help

python3 cli.py --help
python3 cli.py <command> --help  # For command-specific help

πŸŽ₯ Tutorial Video

Screencast_20250710_223520_gfnqkq

πŸ—οΈ Architecture

intermux/
β”œβ”€β”€ core/                   # Core functionality
β”‚   β”œβ”€β”€ interface.py       # Network interface detection
β”‚   └── router.py          # Routing table management
β”œβ”€β”€ gui/                    # GUI components
β”‚   β”œβ”€β”€ app.py             # Main GUI application
β”‚   β”œβ”€β”€ gui.py             # Legacy GUI interface
β”œβ”€β”€ requirements.txt        # Python dependencies
└── README.md              # This file

πŸ”§ How It Works

  1. Interface Detection: Scans system for all network interfaces using ip commands
  2. Routing Tables: Creates custom routing tables in /etc/iproute2/rt_tables
  3. Network Namespaces: Isolates applications using Linux network namespaces
  4. Virtual Interfaces: Uses veth pairs to connect namespaces to physical interfaces
  5. IP Forwarding: Configures NAT/masquerading for namespace connectivity

πŸ› οΈ Advanced Configuration

Custom Routing Table IDs

Edit core/router.py to modify:

BASE_TABLE_ID = 100  # Starting table ID
BASE_PRIORITY = 1000 # Starting priority

πŸ› Troubleshooting

Common Issues

GUI doesn't launch
# Ensure X11 forwarding is enabled
xhost +SI:localuser:root

# Check DISPLAY variable
echo $DISPLAY
Permission denied errors

InterMux requires root privileges for network operations. The GUI uses pkexec for privilege escalation.

# Manual run with sudo
sudo python3 gui/app.py
Interface not detected
# Check interface status
ip link show

# Bring interface up
sudo ip link set <interface> up

πŸ“ Logs and Debugging

Enable verbose logging by modifying core/interface.py:

logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(message)s')

⚠️ Known Limitations

Browser Compatibility

  • βœ… Firefox: Fully supported (/usr/lib/firefox/firefox)
  • ❌ Chromium: Currently not supported due to sandboxing conflicts
  • βœ… Other Applications: Most GUI and CLI applications work correctly

System Requirements

  • Root privileges required for network namespace operations
  • Linux kernel with network namespace support
  • iproute2 package for network management

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Add docstrings to all functions
  • Include type hints where applicable
  • Write unit tests for new features

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with Python and Tkinter
  • Uses Linux networking stack (iproute2)
  • Inspired by the need for better network interface management

πŸ“ž Support


Made with ❀️ for the Linux community