Skip to content

Instantly share code, notes, and snippets.

@pedrolamas
Last active March 10, 2021 18:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrolamas/47e49d44ea885947a3fce69166238f2f to your computer and use it in GitHub Desktop.
Save pedrolamas/47e49d44ea885947a3fce69166238f2f to your computer and use it in GitHub Desktop.
Script to fix Docker iptables on Synology NAS
#!/bin/bash
start() {
iptables -t nat -N DOCKER
iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL ! --dst 127.0.0.0/8 -j DOCKER
}
stop() {
iptables -t nat -D PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
iptables -t nat -D PREROUTING -m addrtype --dst-type LOCAL ! --dst 127.0.0.0/8 -j DOCKER
}
status() {
iptables -t nat -L PREROUTING
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
exit 0
@pedrolamas
Copy link
Author

pedrolamas commented Jun 9, 2020

First, SSH into your Synology, then use sudo su - to enter sudo mode.

Finally, run the following commands to download the script and set the appropriate permissions:

curl https://gist.githubusercontent.com/PedroLamas/47e49d44ea885947a3fce69166238f2f/raw/docker-iptables-fix.sh -o /usr/local/etc/rc.d/docker-iptables-fix.sh
chmod 755 /usr/local/etc/rc.d/docker-iptables-fix.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment