I need to write specific values in the routing system using the iptables command for Android.

The overall idea is that the user can navigate only using the provided DNS configuration.

I've tried to invoke them inside an script through the init.rc, but the script is never called:

service update_iptables /system/bin/update_iptables.sh
    start update_iptables

When I plug the phone to the computer and execute the following sequence, it works without problems:

adb root
adb remount
adb shell /system/bin/update_iptables.sh

Obviously, when restarting, this configuration is lost. That's why I need to run this as part of the start boot sequence.

Any advice on where in init.rc (or any other configuration file) can I place the script?

  • Any file that resides under / is reverted during boot. Your best bet would be to create a script that does your bidding, and place it under /system/etc/init.d. Note that the phone's kernel needs to support init.d, else this won't work.
    – Grimoire
    Mar 11 '17 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.