New Docker options in CSF - how to allow docker ports?
Posted: 27 May 2020, 15:27
I've just noticed the new Docker options in CSF under "Docker Settings", if we enable these do we no longer need to add the following to /etc/csf/csfpre.sh?
Also how can we enable local port access to a Docker container? Is there a way to allow all Docker ports access locally? Here's an example:
Where 7000 is the host port and 8000 is the exposed docker container port. If I turn off CSF I can access the port locally on the same server, turning it back on and the port is blocked. Is there a way to get around this?
Code: Select all
#!/bin/bash
iptables -t nat -N DOCKER
iptables -t nat -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
iptables -t nat -A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
iptables -t nat -A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
iptables -t filter -N DOCKER
iptables -t filter -A FORWARD -o docker0 -j DOCKER
iptables -t filter -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -A FORWARD -i docker0 ! -o docker0 -j ACCEPT
iptables -t filter -A FORWARD -i docker0 -o docker0 -j ACCEPT
Code: Select all
-A DOCKER -d 127.17.0.1/32 ! -i docker0 -p tcp -m tcp --dport 7000 -j DNAT --to-destination 172.17.0.12:8000