[Guide] Tether w/ Bridged AP OpenWrt

Topics addressing TTL settings for Throttling, Tethering and Hotspot Usage
Forum rules
Use the SEARCH function for related topics PRIOR to posting a new topic on the same subject.
Post Reply
ruraltx
Posts: 12
Joined: Fri Feb 25, 2022 12:02 pm
Has thanked: 0
Been thanked: 5 times

[Guide] Tether w/ Bridged AP OpenWrt

Post by ruraltx »

This is a guide for bridging your phone/modem's tether to an OpenWrt (21.02) router. This lets you connect clients through the router's wifi and ethernet, supports ipv4 and ipv6, and includes working rules to modify the TTL/HL of your traffic. On networks that do not use cgnat for ipv6, like T-Mobile, clients will be able to bind to ports and receive inbound traffic from the internet. If you choose to wifi tether, this does not bypass any client limits.

You will probably need to also bypass the APN on your device (example: pcweb.tmobile.com to fast.t-mobile.com for T-Mobile). Some Androids let you run 'settings put global tether_dun_required 0' or add 'dun' to APN type, but YMMV. With root, you can edit APN config file, which always works.

Dependencies:
Go to System -> Software, click 'Update lists', and then dismiss.
Filter and install iptables-mod-ipopt and iptables-mod-physdev
If you are USB tethering:
Also install kmod-usb-net-rndis

Setting Up the Bridge

Select Network -> Interfaces from the top drop-down menu.

Under Interfaces -> LAN, click 'edit'

Under the General Settings tab
Set Protocol to 'Static Address'
(Set an address in the modem's/phone's range, if possible)

Select the DHCP Server tab
Under the General Settings sub-tab
[*]Check the box for ignore interface

Select the IPv6 Settings sub-tab
[*]Set RA-Service to 'disabled'
[*]Set DHCPv6-Service to 'disabled'
[*]Set NDP-Proxy to 'disabled'

Click 'Save'

If you are USB tethering:

Select the Devices tab
Under Devices -> br-lan click 'Configure...'
Under the General device options tab
Add 'usb0' to Bridge ports
Click 'Save' and then 'Save & Apply'

If you are Ethernet tethering:

Delete the WAN and WAN6 interfaces
Select the Devices tab
Under Devices -> br-lan click 'Configure...'
Under the General device options tab
Add 'eth1' to Bridge ports
Click 'Save' and then 'Save & Apply'
Your modem/phone will need to plug into the wan port.

EDIT: Removed the bit on hotspotting as OpenWRT does not support wireless bridging. Would apply more to other firmwares like DD-WRT.


Modify TTL/HL for Bridged Traffic

Add in System -> Startup, under the Local Startup tab

Code: Select all

sysctl -w net.bridge.bridge-nf-call-arptables=1
sysctl -w net.bridge.bridge-nf-call-iptables=1
sysctl -w net.bridge.bridge-nf-call-ip6tables=1

iptables -t mangle -I POSTROUTING -m physdev --physdev-out usb0 -m ttl ! --ttl-eq 255 -j TTL --ttl-set 65
ip6tables -t mangle -I POSTROUTING -m physdev --physdev-out usb0 -m hl ! --hl-eq 255 -j HL --hl-set 65
This goes before "exit 0". The interface is set for USB tethering in this example. Change it if your tethering with a different interface(wlan0, eth1, etc)

The added '-m hl ! --hl-eq 255' with a hop limit of 255. Without it, IPv6 Neighbor Discovery does not work.
ruraltx
Posts: 12
Joined: Fri Feb 25, 2022 12:02 pm
Has thanked: 0
Been thanked: 5 times

Re: [Guide] Tether w/ Bridged AP OpenWrt

Post by ruraltx »

Modify TTL/HL for Bridged Traffic Using Traffic Control

*Don't use this, use the method above. This is here just to document an alternative method.

Code: Select all

opkg update
opkg install tc
opkg install kmod-sched
opkg install iptables-mod-physdev
opkg install iptables-mod-ipopt

Code: Select all

sysctl -w net.bridge.bridge-nf-call-arptables=1
sysctl -w net.bridge.bridge-nf-call-iptables=1
sysctl -w net.bridge.bridge-nf-call-ip6tables=1

iptables -t mangle -A FORWARD -m physdev --physdev-out usb0 -m ttl ! --ttl-eq 255 -j MARK --set-mark 0x200
ip6tables -t mangle -A FORWARD -m physdev --physdev-out usb0 -m hl ! --hl-eq 255 -j MARK --set-mark 0x201

tc qdisc add dev usb0 root handle ffff: htb
tc filter add dev usb0 protocol ip parent ffff:0 handle 0x200 fw action pedit ex munge ip ttl set 65 pipe csum iph
tc filter add dev usb0 protocol ipv6 parent ffff:0 handle 0x201 fw action pedit ex munge ip6 hoplimit set 65 pipe csum iph
singularity8
Posts: 3
Joined: Fri May 13, 2022 2:24 pm
Has thanked: 0
Been thanked: 0

Re: [Guide] Tether w/ Bridged AP OpenWrt

Post by singularity8 »

I'm stuck on this part of the guide for creating the bridge

Code: Select all

If you are Ethernet tethering:

Delete the WAN and WAN6 interfaces
Select the Devices tab
Under Devices -> br-lan click 'Configure...'
Under the General device options tab
Add 'eth1' to Bridge ports
Click 'Save' and then 'Save & Apply'
Your modem/phone will need to plug into the wan port.

I don't see a "Devices Tab"

https://imgur.com/a/gHzxGda
ruraltx
Posts: 12
Joined: Fri Feb 25, 2022 12:02 pm
Has thanked: 0
Been thanked: 5 times

Re: [Guide] Tether w/ Bridged AP OpenWrt

Post by ruraltx »

singularity8 wrote: Mon May 16, 2022 4:00 pm I'm stuck on this part of the guide for creating the bridge...I don't see a "Devices Tab"
Sorry I didn't catch this. On previous OpenWRT, instead of

Code: Select all

Under Devices -> br-lan click 'Configure...'
Under the General device options tab
Add 'eth1' to Bridge ports
you'd add the interface here

Code: Select all

Network at the top menu -> Interfaces
Interfaces tab -> LAN interface -> Edit
Physical Settings tab
Add 'eth1' to Interface
Post Reply

Return to “TTL Settings - Throttling, Tethering and Hotspot Usage”