[Kernel][Pixel4a5g(bramble)] Iptables TTL/Tether LineageOS 18.1

Search This thread

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
This is a recompiled/modified kernel from LineageOS, see that thread for details: https://forum.xda-developers.com/t/rom-official-bramble-lineageos-18-1.4223697/ . This is the kernel they use: https://github.com/LineageOS/android_kernel_google_redbull. Head over to that thread to thank them for all that they do!

The only change I made was I added the required iptables kernel modules for TTL/Tether/unmetering for using your phone as a hotspot. I have Tmobile & with my plan, when I connect any device to the phone it is extremely throttled to around 0.5Mbps. With this kernel, and the settings below, you can get around that limitation. Root is required, so steps to do that are below as well. I am actually very new working with kernels so feel free to weigh in if you have comments or thoughts. For that reason I can't actually indicate what ROMs this will be compatible with, besides what I used, which is: lineage-18.1-20210620-nightly-bramble-signed.zip

I also have these for the Pixel 3a & 4a - if there's interest I'll share those.


All steps to go from stock Pixel -> LineageOS & this Kernel:

  • Install windows driver: Device Manager->Find Pixel->Update driver->Search Android SDK/extras/google/usb_driver
    • Device Mgr->View->Show hidden devices->
    • Should see "Android Composite ADB Interface" when phone connected in ADB mode
    • Should see "Android Device/Android Bootloader Interface" (when phone connected & in fastboot)
  • Install Android SDK/ADB tools
  • May need to use Tmobile Device Unlock app to get a permanent unlock, which allows OEM unlock option in next step
  • Enable developer options if not already
    • Turn on USB debugging
    • Enable OEM unlock. If greyed out: check above step, might need to do a factory reset if above wasnt successful
  • Connect phone to PC via USB cable
  • CMD (sdk/platform-tools/)
    • adb devices (should show device attached-will need to allow on phone)
  • Fastboot mode: Turn off device-> Hold vol down btn + Hold pwr btn-> Notice fastboot screen
    • OR: adb reboot bootloader
  • PC Cmd: (WILL LOSE ALL DATA doing this!!)
    • fastboot flashing unlock
    • Should see message/warning on phone
    • Use vol up/down + pwr btns to select "allow bootloader unlock"
    • This will FACTORY reset!!

  • Unlock Bootloader if not already done
  • Backup your files - this will DELETE ALL OF YOUR DATA
  • Download the latest LineageOS build
  • Reboot to bootloader
    • adb reboot bootloader
  • Flash boot image/recovery:
    • fastboot flash boot lineage-18.1-[WHATEVER]-recovery-bramble.img
    • Vol+ btn to select Recovery Mode -> Pwr btn
    • Should reboot on Recovery screen
  • Factory reset/wipe data:
    • Select Factory reset...
  • Flash ROM:
    • Apply Update-> Apply from ADB
    • adb sideload lineage-18.1-[WHATEVER]-signed.zip
    • Advanced-> Reboot to Recovery-> Apply Update-> Apply from ADB ->
    • adb sideload MindTheGapps-11.0.0-arm64-[WHATEVER].zip ->YES
    • Magisk/Root: Apply Update-> Apply from ADB ->
      • adb sideload Magisk-v23.0.apk
    • Flash my custom Kernel
      • Reboot to Bootloader
      • Download & Unzip boot_KevinTTL.zip -> boot_KevinTTL.img (file is in this post)
      • fastboot flash boot boot_KevinTTL.img
    • Reboot System Now
    • Phone should boot to Android for the first time, go through initial setup

  • Verify Magisk is installed correctly.
  • Download Termux app
  • Termux App:
    • su (Grant permissions)
    • iptables -t mangle -A POSTROUTING -j TTL --ttl-set 64 (should be no errors - if you have errors my kernel is not installed)
  • Test: Turn on phone Hotspot, connect any device, do a speed test comparing speed on phone should be similar to the connected device.
  • If any limitations/blocks: (Not sure but maybe http vs https is blocked sometimes)
    • Install VPN Hotspot app (Green key icon): "Wi-Fi hotspot" ON, wlan1 ON, DISABLE "Tethering HW Acceleration" in settings

This probably goes without saying, but disable System & Lineage updates!

Files:
Magisk: https://github.com/topjohnwu/Magisk/releases/tag/v23.0
ROM files & thread: https://forum.xda-developers.com/t/rom-official-bramble-lineageos-18-1.4223697/
 

Attachments

  • boot_KevinTTL.zip
    19.9 MB · Views: 137
Last edited:

SavakSYN

Member
Dec 4, 2014
22
6
Can we have this added to the official LineageOS kernel for bramble? Or else you'd have to continuously release an update whenever the kernel gets updated in the official build. Thanks!
 

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
Can we have this added to the official LineageOS kernel for bramble? Or else you'd have to continuously release an update whenever the kernel gets updated in the official build. Thanks!
Hopefully someone else can chime in - I'm with you though. It would be cool if added officially, but I don't know how to go about that. They may not be doing it for a reason? I've seen similar Magisk modules that do this but I'm not sure if I can do it for this build (have too much time in this already). But if done via Magisk then that would kind of solve the issue at hand...
 

fddm

Senior Member
Feb 24, 2011
258
171
You can take the module you built while compiling the kernel and make a Magisk module that places it somewhere in system and loads it into the kernel with insmod at boot. I don't think Lineage enforces signatures on modules, so no issue there, and it will generally continue working through all future updates.

The real issue I see is that your not blocking ipv6. Without doing that, this solution is only partially working. The ndc commands to do that are:
Code:
ndc interface ipv6 rndis0 disable
ndc interface ipv6 wlan0 disable
These commands set net.ipv6.conf.[interface].disable_ipv6 to 1. Applying this to wlan0 will disable ipv6 for wifi as well, but it's the best you can do without writing an app or using automation software.
 
Last edited:

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
You can take the module you built while compiling the kernel and make a Magisk module that places it somewhere in system and loads it into the kernel with insmod at boot. I don't think Lineage enforces signatures on modules, so no issue there, and it will generally continue working through all future updates.

The real issue I see is that your not blocking ipv6. Without doing that, this solution is only partially working. The ndc commands to do that are:
Code:
ndc interface ipv6 rndis0 disable
ndc interface ipv6 wlan0 disable
These commands set net.ipv6.conf.[interface].disable_ipv6 to 1. Applying this to wlan0 will disable ipv6 for wifi as well, but it's the best you can do without writing an app or using automation software.
Anyone know how to do this via a Magisk module? Or any clue? I tried several times but Im obviously not doing it right. These are the changes I'm making to the kernel config before compiling: (They allow the iptables function we need to set the TTL)

CONFIG_NETFILTER_XT_TARGET_HL=y
CONFIG_NETFILTER_XT_TARGET_HMARK=y
 

fddm

Senior Member
Feb 24, 2011
258
171
I checked the kernel config, and looks like it should work. You might try this template:
I placed the module in /product/etc here, it's easy enough to change that to wherever is convenient.
 

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
It took me quite some time to compile AOSP's kernel (I always find it to be pretty buggy). I added in the options:

CONFIG_NETFILTER_XT_TARGET_HL=y
CONFIG_NETFILTER_XT_TARGET_HMARK=y

But I didn't get a xt_hl.ko output file, I only got a xt_hl.o file. Any idea if that will work? Or a way (or easier way) to get this file? I'm thinking they are not universal and specific to a device or something like that.
 

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
Try m to build modules, y is for builtin.
Those config options do work. You can tell because without those options you cannot run the iptables ttl cmd. With this options the command succeeds. But for some reason there is no ko file. Will the other format work? I'm not really familiar with "make" but there may be a way to build/compile just the xt_hl file without the rest of the build
 

fddm

Senior Member
Feb 24, 2011
258
171
CONFIG_NETFILTER_XT_TARGET_HL=m
'y' does not build a .ko because it gets built into the kernel. The 'm' option builds as a module.
 
  • Like
Reactions: kevin71246

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
That worked! (changing y=>m gave me a ko file)

This is the xt_HL.ko file from AOSPKernel: android-msm-redbull-4.19-android12, for bramble, in case anyone wants it. I'll try this with the Magisk method when I get a chance. Again, I have no clue what the compatibility will be on this file.

BTW https://android.googlesource.com/kernel/manifest/+refs indicates the AOSP kernels for bramble (Pixel4a5g) (redbull kernel):
 

Attachments

  • xt_HL(android-msm-redbull-4.19-android12).zip
    2.3 KB · Views: 40
Last edited:

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
Attaching xt_HL for Android11/lineage-18.1 in case anyone needs it.

Anyone know why AOSP in general is so buggy to build? Like missing files, config path issues, etc. I have issues everytime, across devices, versions. But when I build LineageSO I typically don't have any issues; it just works!
 

Attachments

  • xt_HL(Android11-lineage-18.1).zip
    2.3 KB · Views: 31

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
I tested the module and I believe it works! How do I know? I ran the cmd: "iptables -t mangle -A POSTROUTING -j TTL --ttl-set 64" on a rooted only boot.img and I got an error. THEN I installed the (attached) Magisk module and it was successful.

I say it that way because I had strange testing results. I connected my laptop to my phones hotspot on a 5g connection & got very fast speed (80Mbps+) (it initially had the TTL setting). Then I deleted the rule "iptables -t mangle -D POSTROUTING -j TTL --ttl-set 64", restarted the phone and got the same fast speed test. Then I installed the stock Lineage18.1 boot.img (no ttl setting) & got the same fast speed! Then I rooted that image & installed. Same results. So it's almost like its persistent - but I can't understand how that can be. I tested my wife's phone (Pixel 4a) to my laptop and I get 0.6Mbps, as I'd expect.

So...if anyone wants to test...please report your results. Again, I can't comment on compatibility, BUT I currently have a LineageOS18.1 build from 6/2021, and this module was built against LineageOS18.1 from this week and it works fine. I attached 2 modules just in case: 1 is for AOSP Android12 (since LineageOS19 official isnt available for our phone yet) as well as for LineageOS18.1.

Thanks @fddm for your help!
 
Last edited:

guest00x

Member
Mar 12, 2022
5
0
Hello,
The iptables command seem to stick but tether still throttled.
Android 11 build rq1c210205.006 with this kernel boot file. I have also tried android 12 with ttl patched kernel but tether still throttle. Any suggestion of the issue?
 

kevin71246

Senior Member
Nov 13, 2008
221
175
Chicago
Hello,
The iptables command seem to stick but tether still throttled.
Android 11 build rq1c210205.006 with this kernel boot file. I have also tried android 12 with ttl patched kernel but tether still throttle. Any suggestion of the issue?
Tmobile? How are you testing, speedtest.net or similar? What is linked device? If a PC, try setting ttl in PC registry to 65 (Google it) I believe (when it then hits the phone it'll naturally go to expected 64 value) & test
 

guest00x

Member
Mar 12, 2022
5
0
Yes. It is tmobile voice sim. TTL seem to work with ping to google give 64, 65, 66 from mac via usb ethernet or wifi. But speed test is .60 dl (exceeded HS data) and and iphone connected via wifi speed test yield same speed .6. ifconfig show many interfaces but ttl mangle did not specify any so it should apply to all.


I have other MR1100/5100 and ttl Bypass work.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    This is a recompiled/modified kernel from LineageOS, see that thread for details: https://forum.xda-developers.com/t/rom-official-bramble-lineageos-18-1.4223697/ . This is the kernel they use: https://github.com/LineageOS/android_kernel_google_redbull. Head over to that thread to thank them for all that they do!

    The only change I made was I added the required iptables kernel modules for TTL/Tether/unmetering for using your phone as a hotspot. I have Tmobile & with my plan, when I connect any device to the phone it is extremely throttled to around 0.5Mbps. With this kernel, and the settings below, you can get around that limitation. Root is required, so steps to do that are below as well. I am actually very new working with kernels so feel free to weigh in if you have comments or thoughts. For that reason I can't actually indicate what ROMs this will be compatible with, besides what I used, which is: lineage-18.1-20210620-nightly-bramble-signed.zip

    I also have these for the Pixel 3a & 4a - if there's interest I'll share those.


    All steps to go from stock Pixel -> LineageOS & this Kernel:

    • Install windows driver: Device Manager->Find Pixel->Update driver->Search Android SDK/extras/google/usb_driver
      • Device Mgr->View->Show hidden devices->
      • Should see "Android Composite ADB Interface" when phone connected in ADB mode
      • Should see "Android Device/Android Bootloader Interface" (when phone connected & in fastboot)
    • Install Android SDK/ADB tools
    • May need to use Tmobile Device Unlock app to get a permanent unlock, which allows OEM unlock option in next step
    • Enable developer options if not already
      • Turn on USB debugging
      • Enable OEM unlock. If greyed out: check above step, might need to do a factory reset if above wasnt successful
    • Connect phone to PC via USB cable
    • CMD (sdk/platform-tools/)
      • adb devices (should show device attached-will need to allow on phone)
    • Fastboot mode: Turn off device-> Hold vol down btn + Hold pwr btn-> Notice fastboot screen
      • OR: adb reboot bootloader
    • PC Cmd: (WILL LOSE ALL DATA doing this!!)
      • fastboot flashing unlock
      • Should see message/warning on phone
      • Use vol up/down + pwr btns to select "allow bootloader unlock"
      • This will FACTORY reset!!

    • Unlock Bootloader if not already done
    • Backup your files - this will DELETE ALL OF YOUR DATA
    • Download the latest LineageOS build
    • Reboot to bootloader
      • adb reboot bootloader
    • Flash boot image/recovery:
      • fastboot flash boot lineage-18.1-[WHATEVER]-recovery-bramble.img
      • Vol+ btn to select Recovery Mode -> Pwr btn
      • Should reboot on Recovery screen
    • Factory reset/wipe data:
      • Select Factory reset...
    • Flash ROM:
      • Apply Update-> Apply from ADB
      • adb sideload lineage-18.1-[WHATEVER]-signed.zip
      • Advanced-> Reboot to Recovery-> Apply Update-> Apply from ADB ->
      • adb sideload MindTheGapps-11.0.0-arm64-[WHATEVER].zip ->YES
      • Magisk/Root: Apply Update-> Apply from ADB ->
        • adb sideload Magisk-v23.0.apk
      • Flash my custom Kernel
        • Reboot to Bootloader
        • Download & Unzip boot_KevinTTL.zip -> boot_KevinTTL.img (file is in this post)
        • fastboot flash boot boot_KevinTTL.img
      • Reboot System Now
      • Phone should boot to Android for the first time, go through initial setup

    • Verify Magisk is installed correctly.
    • Download Termux app
    • Termux App:
      • su (Grant permissions)
      • iptables -t mangle -A POSTROUTING -j TTL --ttl-set 64 (should be no errors - if you have errors my kernel is not installed)
    • Test: Turn on phone Hotspot, connect any device, do a speed test comparing speed on phone should be similar to the connected device.
    • If any limitations/blocks: (Not sure but maybe http vs https is blocked sometimes)
      • Install VPN Hotspot app (Green key icon): "Wi-Fi hotspot" ON, wlan1 ON, DISABLE "Tethering HW Acceleration" in settings

    This probably goes without saying, but disable System & Lineage updates!

    Files:
    Magisk: https://github.com/topjohnwu/Magisk/releases/tag/v23.0
    ROM files & thread: https://forum.xda-developers.com/t/rom-official-bramble-lineageos-18-1.4223697/
    1
    CONFIG_NETFILTER_XT_TARGET_HL=m
    'y' does not build a .ko because it gets built into the kernel. The 'm' option builds as a module.
    1
    My mr1100 definitely used tmoble voice sim with exceeded hs data and it work with ttl bypass. Because when i remove the ttl bypass it limited to .6. I am not sure why this phone is not working. I tried ttl for each interface but does not work. The problem is when i ping google via mac ttl:64/65/66 but speed is throttled to .6
    Try the iptables config along with this & retest:

    • Download "VPN Hotspot" app in playstore (Green key icon): "Wi-Fi hotspot" ON, wlan1 ON, DISABLE "Tethering HW Acceleration"