Unable to REDIRECT in lineageos 14.1 (Android 7.1)

Hi all!

I was trying to use mitmproxy with my android device. I first setup the normal proxy mode, and it was working even for SSL packets, but not for every application (as stated in the Docs). Then i tried to setup Transparent Proxy mode, following Docs page step by step, and here are the problems:

  • I tried to set default gateway first from wifi settings. I think it’s working because i get No Internet Connection at first.
  • Using adb root shell I added iptables rules for REDIRECT to 8080, but it seems like android is completely ignoring those rules. I also added some other rules like
    iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 80 -j DNAT -–to-destination <mitmproxy_host>:8080
    iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 443 -j DNAT -–to-destination <mitmproxy_host>:8080
    but again, android ignores them.
  • I also tried to set up default gateway using ip route add command, but it seems android is ignoring even this rule.

Do you have any clue about the problem? Thanks in advance!