[5.0+][ROOT][3.6.0] AFWall+ IPTables Firewall [28 AUG 2023]

Search This thread

notNSA

Member
Jun 12, 2021
7
5
SEVERE SECURITY WARNING:
AFWALL default functionality might NOT (and probably for many will NOT) secure your Android phone.

EXPECTED BEHAVIOR:
A secure firewall must block incoming connections that are not initiated by the user.

ACTUAL BEHAVIOR:
a) using the latest version 3.5.2 and I discovered erratic behavior by the app when trying to run a custom script to set incoming packet policy to DROP and accept only related and established incoming connections. AFWall errored out when trying to set the rules.

b) depending on your ROM you might have INPUT chain rules that need to be vetted, which relies on custom scripting errors out. For example, a Samsung stock Rom on a 2020 device has "input_dos" chain rule within INPUT chain that explicitly allows ctstate "NEW" packets through. Must not happen in a secure firewall that only wants to accept established and related state incoming packets.

WORKAROUND:
What works for the time being as a workaround is:

a) set up AFWall focusing on app permissions which should cover the OUTPUT part of the firewall.

b) change the INPUT chain rules manually via terminal to drop incoming packets except for established/related connection state packets and remove rules that bypass this restriction.

------
This tight INPUT chain has nearly doubled my battery life (4000 mAh Li-Po from 10hrs to 20 hrs).
 
Last edited:

FFW

Senior Member
May 24, 2020
74
49
Thanks for your explanation of "Clat"!
Just a last guess: How is your handling of IPv4 and IPv6 Chains?
I can't use IPv6, so I didn't enable it.

This is the setting of my Moto G Play phone and Samsung Galaxy Tab S2, both LOS 17.1:

View attachment 5340641
I have it active. Adjusting the setting what I see on your screenshot does not help as well though. It seems either my XZ1 Compact is in some way different - or my Wireguard VPN makes a difference ;-)

Well, I still hope from some ideas from @ukanth - either here or on his github site... but thanks for trying to help!

Edit: I found one difference between our settings though: If I set the "Input chain" setting to "blocked", Wireguard (and thus, anything else) does not get any web access on 3.4.0 as well. Might be logical since AFAIK Wireguard acts as a local "router interface". So this is a clear difference between your devices and mine.

Maybe there is some change between 3.4.0 and 3.5.x that causes this chain setting to break...?
 
Last edited:

eriol1

Senior Member
Feb 16, 2015
218
157
SEVERE SECURITY WARNING:
AFWALL default functionality might NOT (and probably for many will NOT) secure your Android phone.

EXPECTED BEHAVIOR:
A secure firewall must block incoming connections that are not initiated by the user.

ACTUAL BEHAVIOR:
a) using the latest version 3.5.2 and I discovered erratic behavior by the app when trying to run a custom script to set incoming packet policy to DROP and accept only related and established incoming connections. AFWall errored out when trying to set the rules.

b) depending on your ROM you might have INPUT chain rules that need to be vetted, which relies on custom scripting errors out. For example, a Samsung stock Rom on a 2020 device has "input_dos" chain rule within INPUT chain that explicitly allows ctstate "NEW" packets through. Must not happen in a secure firewall that only wants to accept established and related state incoming packets.

WORKAROUND:
What works for the time being as a workaround is:

a) set up AFWall focusing on app permissions which should cover the OUTPUT part of the firewall.

b) change the INPUT chain rules manually via terminal to drop incoming packets except for established/related connection state packets and remove rules that bypass this restriction.

------
This tight INPUT chain has nearly doubled my battery life (4000 mAh Li-Po from 10hrs to 20 hrs).
AFAIK, AFWall never claimed to block any incoming connections. The main purpose is to block unwanted outgoing connections.
Android itself maybe blocks some incoming connections? but android probably has a very different idea of what an unwanted connection is 😬

Nevertheless, thanks for the important info and nice effect on the battery (y)
 
b) change the INPUT chain rules manually via terminal to drop incoming packets except for established/related connection state packets and remove rules that bypass this restriction.

My custom start-up script with DROP-policy for unwanted (not whitelisted) incoming traffic fortunately doesn't produce errors on v3.5.2.1.

Often after booting up the phone AFWall+ can't get root access despite Magisk is set to grant it always. AFWall+ then disables the firewall. I start it again, enable firewall and the script and rules get applied. A somehow peculiar behaviour ...

---
Edit: Also tried to work with timeouts before getting the rules applied. This doesn't help, either.
 
Last edited:

Tappad

Member
Nov 18, 2015
9
1
I had AFwall+, worked like a charm. Had to wipe my phone and I did export my rules etc but I can only import them on the pro version, which I cant afford atm. But I once found a guide to help me with which apps/functions to block but I cant seem to find it now.

So, any idea where I can find a guide describing what ex multicast is and what to block etc?
 

Kilito!!*-*

New member
Oct 14, 2020
1
0
Uh ... I need a little help



It's been a long time since I found that thing that says "AppID : -1"



My cell phone overheats because it tries to connect to the internet about 20,000 times every time I look at it, and this is the only application where there is any evidence of this so I wanted to know if you know what it is...



I've tried to find the application that causes this in many ways but can't find anything



Uh ... help
Screenshot_20210627-204754_AFWall+.jpg
 

PietZeHut

Member
Apr 29, 2021
14
0
Hi All,
my moto g7 power is unlocked, has LOS18 (lineage-18.1-20210724-nightly-ocean) installed and is using AFWall+.
Unfortunately AFWall is blocknig other devices to connect to my moto g7 power via wifi tethering.
Can anyone guide me how to configure AFWall to allow it?
Many thanks !
 

EngineerMind

Senior Member
May 5, 2007
783
229
I know this may sound like a newbie question, but I just want to understand how this app works.

From what I understand, it modifies the "IPTables" which I believe are config files that tell the internal network system how to route data packets.

So, if this app modifies the IPTables files to apply my rules, then why when I reboot my device, it displays "Applying Rules" again on boot up? Meaning, if the IPTables were modified when I last used this app, then I would think these IPTables files would remember their settings in-between boots, so there should be no reason to reapply them after a reboot. So why does this app need to reapply the same rules after a reboot?

Or is it that any changes to the IPTables are only valid for the current device session, and when the device gets rebooted, the iptables are cleared, and that is why this app needs to reapply them?

If this second theory is the case, then does that mean that apps (that I blocked in afall) will be able to reach the internet for the first ~30 seconds right when the device is booting up, but before afwall+ has the chance to reapply the rules?
 
  • Like
Reactions: TiTiB
I know this may sound like a newbie question, but I just want to understand how this app works.

From what I understand, it modifies the "IPTables" which I believe are config files that tell the internal network system how to route data packets.
No it is not any config files...
It is the name of the networking functionality of the kernel.
It's rules are kept in memory and need to be reapplied after each boot.
 
Wow - so apps can get internet access for around a minute right after bootup (before afwall can apply the rules).
That could be the case, I don't know because I haven't used AFWall for years so I don't know how and when it applies the rules.
My answer is from a general Linux knowledge point of view. ;)
 

b00b

Senior Member
Oct 24, 2010
198
53
Wow - so apps can get internet access for around a minute right after bootup (before afwall can apply the rules).
yes they cld and thats all some apps need so as to send info home but the simplest way around that is to turn off mobile internet as well as wifi before reboot and wait about a minute after boot for the firewall to have started before reconnecting internet access :)
 
Last edited:

EEngineer

Senior Member
Oct 20, 2011
954
173
USA
T-Mobile LG G5
yes they cld and thats all some apps need so as to send info home but the simplest way around that is to turn off mobile internet as well as wifi before reboot and wait about a minute after boot for the firewall to have started before reconnecting internet access :)
I have AFWall+ and before I reboot or shut down my phone (which is at least once a week) I put my phone in airplane mode first.

I also have "Fix startup data leak" greyed out, and I have both int.d and SU installed. What's the deal?
 

Uluru25

Senior Member
Nov 27, 2016
652
343
Samsung Galaxy S7
Samsung Galaxy A6
I have two questions:

1) How do i use the "Startup Directory Path for Script" setting?
2) The "Fix startup data leak" is greyed out - is this because I have Magisk (systemless)?
Just click (first!) on the startup directory path and activate it here. Then the outgreying of fixing the startup data leak will dissappear and you can activate it.
 

Attachments

  • Screenshot_20210729-194442_Trebuchet.png
    Screenshot_20210729-194442_Trebuchet.png
    159.9 KB · Views: 30

Top Liked Posts

  • 1
    What is needed to be enabled to use Android Auto in my car?
    I'm not sure what you're asking, but AFWall is meant to block traffic based on certain rules. Why would you want to use AFWall in order to enable AA? Are you rooted? Custom ROM? What's your environment? Are you currently able to use AA in your car?
    1
    I'm not sure what you're asking, but AFWall is meant to block traffic based on certain rules. Why would you want to use AFWall in order to enable AA? Are you rooted? Custom ROM? What's your environment? Are you currently able to use AA in your car?

    Perhaps they are having trouble using Android auto with the Firewall, e.g., maybe AFwall is blocking Android Auto.

    +1 to your question/suggestion about whether or not Android Auto works okay when AFwall is not enabled.
    1
    What is needed to be enabled to use Android Auto in my car?
    this sounds like you are using afwall in whitelist mode (blocks everything, and you select what gets access)?

    if you run it in the recommended blacklist mode (allows everything, and you select what gets blocked) you should not have this issue - assuming you don't of course block android auto or some crucial system app.
    1
    What is needed to be enabled to use Android Auto in my car?
    I had to enable traffic for a bunch of XIAOMI system "apps" (they bundle a bunch of apps together so that you don't disable them) that disabled network if they didn't phone home successfully after a couple of minutes. Never buying anything from that underhanded manufacturer EVER AGAIN.
    1
    What is needed to be enabled to use Android Auto in my car?
    What device you are using? OS and app version? What the default filtering mode? There's any logs while your device try to attempt any connection? More info please.
  • 1
    What is needed to be enabled to use Android Auto in my car?
    I'm not sure what you're asking, but AFWall is meant to block traffic based on certain rules. Why would you want to use AFWall in order to enable AA? Are you rooted? Custom ROM? What's your environment? Are you currently able to use AA in your car?
    1
    I'm not sure what you're asking, but AFWall is meant to block traffic based on certain rules. Why would you want to use AFWall in order to enable AA? Are you rooted? Custom ROM? What's your environment? Are you currently able to use AA in your car?

    Perhaps they are having trouble using Android auto with the Firewall, e.g., maybe AFwall is blocking Android Auto.

    +1 to your question/suggestion about whether or not Android Auto works okay when AFwall is not enabled.
    1
    What is needed to be enabled to use Android Auto in my car?
    this sounds like you are using afwall in whitelist mode (blocks everything, and you select what gets access)?

    if you run it in the recommended blacklist mode (allows everything, and you select what gets blocked) you should not have this issue - assuming you don't of course block android auto or some crucial system app.
    1
    What is needed to be enabled to use Android Auto in my car?
    I had to enable traffic for a bunch of XIAOMI system "apps" (they bundle a bunch of apps together so that you don't disable them) that disabled network if they didn't phone home successfully after a couple of minutes. Never buying anything from that underhanded manufacturer EVER AGAIN.
    1
    What is needed to be enabled to use Android Auto in my car?
    What device you are using? OS and app version? What the default filtering mode? There's any logs while your device try to attempt any connection? More info please.
  • 404
    Welcome to official support page for AFWall+

    Disclaimer - As Usual. I'll not take any responsible if something goes wrong when using AFWall+

    Introduction
    AFWall+ is an improved version of DroidWall(front-end application for the powerful iptables Linux firewall). It allows you to restrict which applications are permitted to access your data networks (2G/3G/4G/LTE and/or Wi-Fi and while in roaming).Since the original author of Droidwall
    discontinued the project, I decided to keep the app instead of Avast Firewall. I'll continue to add more features as I can.


    Features
    - Supports 5.x to 13.x
    - Import/Export Rules to external storage
    - Search Applications
    - Multiple Profiles with custom names
    - Tasker/Locale support
    - Select All/None/Invert/Clear applications with single click
    - Revamped Rules/Logs Viewer with copy/export to external storage
    - Ability to view the network interfaces
    - Highlight system applications with custom color
    - Notify on new installations
    - Ability to hide application icons( faster loading )
    - Use LockPattern for application protection.
    - Show/Hide application ID.
    - Roaming Control for 3G/Edge
    - VPN Control
    - LAN Control
    - Tether Control
    - IPV6 Control
    - Tor Control
    - Choose able languages
    - Choose able iptables/busybox binary
    - Supports MIPS/x86/ARM
    - DNS Hostname

    Changelog - See third Post
    Current Version - 3.6.0

    To get Unlocker without Google services - Please follow the instructions here

    AFWall+ BETA Program
    1) AFWall+ opt-in for beta program
    2) Install AFWall+ and If you have any issues, just send email from (Menu -> Firewall Rules - > Send error report)

    Source Code/Wiki/FAQ
    AFWall+ is an free & opensource application
    Github
    Log an issue
    Frequently Asked Questions
    Many Thanks to @CHEF-KOCH

    Translations
    Translations - Please help me with translations in your language.
    http://crowdin.net/project/afwall

    Thanks To/Credits
    - German translations by chef@xda & user_99@xda & Gronkdalonka@xda
    - French translations by GermainZ@xda & Looki75@xda
    - Russian translations by Kirhe@xda & YaroslavKa78
    - Spanish translations by spezzino@crowdin
    - Dutch translations by DutchWaG@crowdin
    - Japanese translation by nnnn@crowdin
    - Ukrainian translation by andriykopanytsia@crowdin
    - Slovenian translation by bunga bunga@crowdin
    - Chinese Simplified translation by tianchaoren@crowdin
    - Polish translations by tst,Piotr Kowalski@crowdin
    - Swedish translations by CreepyLinguist@crowdin
    - Greek Translations by mpqo@crowdin
    - Portuguese translations by lemor2008@xda
    - Chinese Traditional by shiuan@crowdin
    - Chinese Simplified by wuwufei,tianchaoren @ crowdin
    - Italian translations by benzo@crowdin
    - Romanian tranlations by mysterys3by-facebook@crowdin
    - Czech translations by Syk3s

    Cheers,
    ukanth

    XDA:DevDB Information
    AFWall+ [ IPTables Firewall ], App for the Android General

    Contributors
    ukanth
    Source Code: https://github.com/ukanth/afwall


    Version Information
    Status:
    Stable
    Current Stable Version: 3.5.3
    Stable Release Date: 2022-06-28
    Current Beta Version:
    3.5.3
    Beta Release Date: 2022-06-28

    Created 2013-12-03
    Last Updated 2020-09-05
    70
    Version 3.0.1

    * Fix: Status toggle widget 1x1
    * Fix: Ability to hide ongoing notification (Stop firewall and restart to hide after disable it in preferences)
    * Fix: Firewall error notification on oreo and above
    * Security: Tile toggle checks for password
    * User reported crashes
    * Updated translations

    Previous version 3.0.0

    Features:
    * Better support for nougat/oreo and pie.
    * Firewall toggle tile
    * Adaptive Icons
    * Notification channels
    * Tor support

    Bugs:
    * General bug fixes and crash reports.
    * Language selection bug
    * Filter selection bug
    * Compatible with magisk 17.x
    * Better handling of background process
    * Drops support for 4.x devices
    * Update languages
    * Updated libraries

    Complete Changelog

    41
    Hello All,

    After careful analysis and testing, I decided not to rewrite the way rules are being applied due to lot of under hood changes required. Instead added few enhancements. Now applying rules from menu will show how many rules are getting applied with progress status. Also when adding/removing few rules , it will apply only those related rules instead of full apply.

    Also fixed couple of bugs and enhancements. You can get the full changelog from https://github.com/ukanth/afwall/blob/beta/Changelog.md

    This is BETA Version which is not released on playstore. I have been using this for past week and it's stable. But there might be bugs which I haven't encountered. Please test it and report it in case of any issues.

    Also I have been following XPrivacy thread on the decision by it's author. Just as FYI, I might fix it for my own usage when I update to nougat, I will share it here if anybody uses it here.

    BETA Link - https://www.dropbox.com/s/isvi413qyx6vb4d/AFWall+ 2.9.7-BETA-TESTER.apk?dl=0
    40
    Hello everyone,

    I have released 3.0.0 stable on playstore today. It's been a crazy month so far. After going through lot of dilemma of whether to support the existing afwall or write a new one from scratch, finally able to pull myself and release stable version of afwall with lots of bug fixes and new features along with pie support. Since I don't do full time Android development, it was hard to keep track of what's going on with sdk level changes.

    Thank you all for your support in AFWall+ development. Without your support it would simply not possible to pull through this.

    I will be out for couple of days ( taking off to spend time with my family ) and hopefully will be able to reply to questions once back.

    Thanks again and have a great day.
    35
    Hello everyone,

    I have released stable version of 3.1.0 to playstore and github. Its live on playstore. You can find the changelog along with md5/sha here

    https://github.com/ukanth/afwall/releases/tag/v3.1.0

    Thank you all for your continuous support in AFWall+ development.