1. Host Service Ports
| |
This allows only 1.2.3.4 to access port 80 on the local host.
2. Docker Service Ports
For services started like docker run -d -p 80:80 shaowenchen/demo:whoami, the method above does not work; the rule has to be added to the DOCKER-USER chain.
Docker adds its iptables rules to the DOCKER chain, so if you need a rule to take effect before Docker’s, it has to go into the DOCKER-USER chain.
| |
ens192 is the local NIC. This allows only 1.2.3.4 to access port 80 on the local host.
3. Clean Up the Environment
| |
If you want the iptables settings to remain in effect after the host restarts, you need to install iptables-services and save them.
| |
