Created
February 19, 2016 11:09
-
-
Save JrCs/9625c1a21b0762fd8320 to your computer and use it in GitHub Desktop.
Create Posteio container network
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
#!/bin/bash | |
docker network create posteio &>/dev/null | |
id=$(docker network inspect --format "{{.ID}}" posteio 2>/dev/null | cut -c1-12) | |
[[ -z "$id" ]] && exit 1 | |
MASQUERADE=$(iptables -S -t nat | egrep "POSTROUTING.*br-$id.*MASQUERADE") | |
[[ -z "$MASQUERADE" ]] && exit 0 | |
source /etc/environment | |
[[ -z "$POSTEIO_PUBLIC_IPV4" ]] && exit 1 | |
iptables -t nat $(echo "$MASQUERADE" | sed -n "s/^-A/-I/;s/MASQUERADE/SNAT --to-source $POSTEIO_PUBLIC_IPV4/p") | |
iptables -t nat $(echo "$MASQUERADE" | sed -n "s/^-A/-D/p") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment