Skip to main content

Creating a Bonding Router with RUTx50 and AWS EC2

This guide will walk you through setting up a link bonding router using a Teltonika RUTx50 OpenWRT router with an AWS EC2 Ubuntu instance as an internet gateway. This configuration allows you to:

  • Aggregate multiple internet connections (e.g., cellular, Ethernet, Wi-Fi) for increased throughput
  • Provide bonded connectivity to non-HyperPath devices connected to your RUTx50
  • Access the internet securely through your EC2 instance acting as a gateway

Architecture Overview

In this setup, we will:

  1. Create a HyperNet with two nodes:
  • RUTx50 Router: Acts as a bonding router with multiple network interfaces
  • EC2 Instance: Serves as an internet gateway
  1. Configure the EC2 instance to:
  • Forward IP traffic
  • Perform Network Address Translation (NAT)
  • Connect to the internet
  1. Configure the RUTx50 to:
  • Use two WAN interfaces (built-in modem and WiFi WAN link) for bonding
  • Route all internet traffic through the EC2 gateway
  • Provide connectivity to local non-HyperPath devices

Prerequisites

  • A HyperPath account
  • A Teltonika RUTx50 router with firmware version RUTX_R_00.07.11.3 or compatible
  • An AWS EC2 Ubuntu 22.04 LTS instance with:
  • Security group allowing inbound/outbound UDP traffic
  • Basic Ubuntu server setup
info

When following the guide below, make sure you restart the HyperPath service after changing any of the token settings

Step 1: Create a HyperNet

  1. Log in to the HyperPath admin console
  2. Navigate to the HyperNets tab
  3. Click on the "Add HyperNet" button
  4. Provide a name (e.g., "BondingRouterNet") and description
  5. Click the "Create" button

Step 2: Create a Token for the EC2 Gateway

  1. Click on your newly created HyperNet to manage it
  2. Click the "Add Token" button
  3. Configure the token with the following settings:
  • Name: "EC2-Gateway"
  • Expiry Date: Select an appropriate date
  • Description: "Ubuntu EC2 instance serving as internet gateway"
  • IPv4: "10.0.0.1" (or another IP within your HyperNet range)
  • Gateway: Leave empty as this will be the gateway
  • Useable Interfaces: "eth.*" (or whatever the interface name is)
  • External Routes: "" (Leave blank)
  • Setup Multihomed Routing: Unchecked
  1. Click "Add" to create the token
  2. Copy the installation command from the popup for later use

Step 3: Create a Token for the RUTx50 Router

  1. Return to your HyperNet management page
  2. Click the "Add Token" button again
  3. Configure the token with the following settings:
  • Name: "RUTx50-Router"
  • Expiry Date: Select an appropriate date
  • Description: "Bonding router for multiple connections"
  • IPv4: "10.0.0.2" (or another IP within your HyperNet range)
  • Gateway: "EC2-Gateway" (select the gateway node you created earlier)
  • Useable Interfaces: "qmimux0 wlan0-2" (to use the built-in modem as well as WiFi WAN link)
  • External Routes: "" (Leave blank)
  • Setup Multihomed Routing: Unchecked
  1. Click "Add" to create the token
  2. Copy the installation command from the popup for later use

Step 4: Set Up the EC2 Gateway Node

  1. Connect to your EC2 instance via SSH:
ssh -i your-key.pem ubuntu@your-ec2-public-ip
  1. Install HyperPath using the installation command you copied earlier. Check out a more detailed installation guide for Debian-based distros

  2. Verify HyperPath is running:

hyperpath status
  1. Enable IPv4 forwarding to allow the instance to route traffic:
# Enable temporarily
sudo sysctl -w net.ipv4.ip_forward=1

# Enable permanently
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
  1. Configure IP Masquerading to enable NAT for outgoing traffic:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  1. Make the iptables rules persistent across reboots:
sudo apt-get update
sudo apt-get install -y iptables-persistent
sudo netfilter-persistent save

Step 5: Set Up the RUTx50 Router

  1. Connect to your RUTx50 router via SSH:
ssh root@192.168.1.1  # Default IP, may be different in your setup
  1. Install HyperPath using the installation command you copied earlier. Check out a more detailed installation guide for OpenWrt-based distros

  2. Verify HyperPath is running:

hyperpath status
  1. If not running, Start the HyperPath service:
/etc/init.d/hyperpath start
  1. If desirable, configure the service to start automatically on boot:
/etc/init.d/hyperpath enable
  1. Ensure that both the internal 4G/5G modem and a WiFi WAN links are active. The two commands below should show the interfaces having an address assigned to them:
ifconfig qmimux0
ifconfig wlan0-2

Step 6: Verify the Connection

  1. On the RUTx50, check the connection to the EC2 instance:
ping 10.0.0.1  # Replace with your EC2 HyperNet IP
  1. Verify that multiple interfaces are being used for bonding:
hyperpath status

Look for the "Channels" section to confirm multiple P2P connections are established.

  1. Check the internet connection through the bonded link:
ping 8.8.8.8

Step 7: Using the bonded connectivity on local devices

Any device connected to the RUTx50 router will automatically use the bonded connection as long as the RUTx50 is configured as their default gateway.

  1. Connect a device (e.g., laptop, smartphone) to the RUTx50 via Wi-Fi or Ethernet
  2. Ensure the device's network settings are configured to use the RUTx50 as the default gateway (usually done automatically via DHCP)
  3. Verify that the device is using the bonded connection by checking the IP address assigned to it (should be the same public IP as the AWS EC2 machine)
  4. Test the internet connection from the device by running a speed test

Troubleshooting

Connectivity Issues

If nodes aren't connecting:

  1. Verify both nodes show "Running" status:
hyperpath status
  1. Check if the EC2 instance's security group allows UDP traffic

  2. Verify IP forwarding is enabled on the EC2 instance:

cat /proc/sys/net/ipv4/ip_forward

The output should be 1.

  1. Check that MASQUERADE is properly configured:
sudo iptables -t nat -L -n -v

Look for a rule with -j MASQUERADE.

Performance Issues

If bonding performance isn't as expected:

  1. Check that both interfaces are being used:
hyperpath status

If not, double-check the interface names in the "Useable Interfaces" section of the token configuration matches the names of the network interfaces appearing via the ifconfig or similar command.

  1. Ensure the two WAN interfaces (qmimux0, wlan0-2) are up in the Rutx50

  2. Ensure P2P connections are established rather than relay connections for optimal performance

Conclusion

You've now successfully set up a bonding router using a Teltonika RUTx50 with an AWS EC2 instance as your internet gateway. For devices connected to your RUTx50, this setup works transparently - they simply connect to your router as usual and automatically benefit from the bonded connection without any additional configuration.