Skip to content

Instantly share code, notes, and snippets.

@Eidansoft
Last active September 30, 2019 09:59
Show Gist options
  • Save Eidansoft/8a61fe10f8d65a43608ea680ad717d61 to your computer and use it in GitHub Desktop.
Save Eidansoft/8a61fe10f8d65a43608ea680ad717d61 to your computer and use it in GitHub Desktop.
Docker tips
# On a docker container force to not reach Internet/connectivity
# The docker must be started as a privileged with the param --privileged and
# on the running container, you must have iptables installed (apt-get install iptables),
# then you can run:
# To avoid all connectivity at all
iptables -A OUTPUT -j DROP
# Avoid all connectivity on a specific interface
iptables -A OUTPUT -o eth1 -j DROP
# Avoid connectivity to a specific IP
iptables -A INPUT -s 1.2.3.4 -j DROP
# If the restriction must be for a specific port (for example 25), then:
iptables -A INPUT -s 1.2.3.4 -p tcp --destination-port 25 -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment