Created
March 4, 2018 07:43
-
-
Save akoenig/789627651bb9bc82b97c2fcc2df91c30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# | |
# iptables configuration | |
# | |
# The following allows in- and outbound traffic | |
# within a certain `CIDR` (default: `192.168.0.0/24`), | |
# but blocks all other network traffic. | |
# | |
ACCEPT_CIDR=${ALLOWED_CIDR:-192.168.0.0/24} | |
iptables -A INPUT -s $ACCEPT_CIDR -j ACCEPT | |
iptables -A INPUT -j DROP | |
iptables -A OUTPUT -d $ACCEPT_CIDR -j ACCEPT | |
iptables -A OUTPUT -j DROP | |
# | |
# After configuring `iptables` as root, execute | |
# the passed command as the non-privileged `app` user. | |
# | |
sudo -u app sh -c "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment