# Run system command in sandboxed app

**URL:** <https://forum.legato.io/t/run-system-command-in-sandboxed-app/6116>\
**Category:** Uncategorized\
**Created:** [February 17, 2022, 10:31am UTC](https://forum.legato.io/t/run-system-command-in-sandboxed-app/6116 "2022-02-17T10:31:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reinhard](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@Reinhard](https://forum.legato.io/u/Reinhard)\
**Post date:** [February 17, 2022, 10:31am UTC](https://forum.legato.io/t/run-system-command-in-sandboxed-app/6116/1 "2022-02-17T10:31:15Z")

</div>

I need to add/remove iptables rules inside my legato app how can i do that?  
The app must sandboxed. To use an unsandboxed app is not an option!

I check a GPIO and if the GPIO is set to high i need to execute the following command:

iptables -t nat -A POSTROUTING --out-interface rmnet\_data0 -j MASQUERADE  
iptables -A FORWARD -o ecm0 -i rmnet\_data0 -m state --state RELATED,ESTABLISHED -j ACCEPT  
iptables -A FORWARD -i ecm0 -o rmnet\_data0 -j ACCEPT  
echo 1 \> /proc/sys/net/ipv4/ip\_forward

Thanks in advanced!

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 17, 2022, 10:34am UTC](https://forum.legato.io/t/run-system-command-in-sandboxed-app/6116/2 "2022-02-17T10:34:51Z")

</div>

it is quite hard to implement this in sandboxed application.

I suggest you to build an unsandboxed application to just call these iptables commands.  
And then in your sandboxed application, when you need to set iptables rules, you can use IPC to call your unsandboxed application.

---

<div class="post-metadata">

**Author:** ![Reinhard](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@Reinhard](https://forum.legato.io/u/Reinhard)\
**Post date:** [February 17, 2022, 10:54am UTC](https://forum.legato.io/t/run-system-command-in-sandboxed-app/6116/3 "2022-02-17T10:54:58Z")

</div>

Thanks for the quick Answer!

Is there really no way to do this in a single sandboxed app?

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [February 17, 2022, 11:08am UTC](https://forum.legato.io/t/run-system-command-in-sandboxed-app/6116/4 "2022-02-17T11:08:16Z")

</div>

you can try porting the iptables source code to your application.
