# How to execute task after every reboot from host OS?

**URL:** <https://forums.balena.io/t/how-to-execute-task-after-every-reboot-from-host-os/47802>\
**Category:** balenaOS\
**Tags:** systemd\
**Created:** [November 29, 2019, 4:47am UTC](https://forums.balena.io/t/how-to-execute-task-after-every-reboot-from-host-os/47802 "2019-11-29T04:47:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbedare](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@mbedare](https://forums.balena.io/u/mbedare)\
**Post date:** [November 29, 2019, 4:47am UTC](https://forums.balena.io/t/how-to-execute-task-after-every-reboot-from-host-os/47802/1 "2019-11-29T04:47:38Z")

</div>

I want to run iptables like commands after every reboot. These commands are not available from container. I tried systemd but since /etc/systemd is read-only, I am not able to add new service which will execute these tasks. Alternatively, is there a way to run iptables from container?

---

<div class="post-metadata">

**Author:** ![robertgzr](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/robertgzr/32/1387_2.png) [@robertgzr](https://forums.balena.io/u/robertgzr)\
**Post date:** [November 29, 2019, 10:34am UTC](https://forums.balena.io/t/how-to-execute-task-after-every-reboot-from-host-os/47802/3 "2019-11-29T10:34:23Z")

</div>

Hi if you run a multicontainer application you can give a container access to the host network namespace, NETWORK\_ADMIN capability and install the iptables command. Those together should enable you run the command from a container.

---

<div class="post-metadata">

**Author:** ![robertgzr](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/robertgzr/32/1387_2.png) [@robertgzr](https://forums.balena.io/u/robertgzr)\
**Post date:** [November 29, 2019, 10:39am UTC](https://forums.balena.io/t/how-to-execute-task-after-every-reboot-from-host-os/47802/4 "2019-11-29T10:39:02Z")

</div>

Here are some links for you:

- host networking: [https://docs.docker.com/network/host/](https://docs.docker.com/network/host/) `--network=host`
- kernel capabilities: [https://docs.docker.com/engine/security/security/#linux-kernel-capabilities](https://docs.docker.com/engine/security/security/#linux-kernel-capabilities) you would need `--cap-add=NET_ADMIN`

---

<div class="post-metadata">

**Author:** ![mbedare](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@mbedare](https://forums.balena.io/u/mbedare)\
**Post date:** [November 30, 2019, 1:29am UTC](https://forums.balena.io/t/how-to-execute-task-after-every-reboot-from-host-os/47802/6 "2019-11-30T01:29:01Z")

</div>

Thanks ton Robert. I could install iptables using your suggestion.
