Skip to content

Instantly share code, notes, and snippets.

@jeansf
Last active September 5, 2020 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeansf/5645c5fc35697944db1ec2a2978ffe4f to your computer and use it in GitHub Desktop.
Save jeansf/5645c5fc35697944db1ec2a2978ffe4f to your computer and use it in GitHub Desktop.
BBB Support
PIP=111.111.111.111
DIP=222.222.222.222
iptables -t nat -A OUTPUT -j DNAT -d $PIP --to-destination $DIP
CID=bbb
PS=16384
PE=32768
CIP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CID)
echo "Ports: $PS:$PE/udp redirect to IP Container: $CIP"
iptables -A DOCKER -t nat -p udp -m udp ! -i docker0 --dport $PS:$PE -j DNAT --to-destination $CIP:$PS-$PE
iptables -A DOCKER -p udp -m udp -d $CIP/32 ! -i docker0 -o docker0 --dport $PS:$PE -j ACCEPT
iptables -A POSTROUTING -t nat -p udp -m udp -s $CIP/32 -d $CIP/32 --dport $PS:$PE -j MASQUERADE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment