Skip to content

Instantly share code, notes, and snippets.

@tkachev-o
Created April 5, 2023 10:36
Show Gist options
  • Save tkachev-o/333f151b3488874dfbe4a600a401d2d5 to your computer and use it in GitHub Desktop.
Save tkachev-o/333f151b3488874dfbe4a600a401d2d5 to your computer and use it in GitHub Desktop.
DOCKER-USER block port

Allow form IP

ur@sr:~# iptables -I DOCKER-USER -i eth0 -p tcp -m conntrack --ctorigdstport 8080 --ctdir ORIGINAL -j DROP
ur@sr:~# iptables -I DOCKER-USER -i eth0 -s <YOUR_IP> -p tcp -m conntrack --ctorigdstport 8080 --ctdir ORIGINAL -j ACCEPT

Show result

ur@sr:~# iptables -L DOCKER-USER
Chain DOCKER-USER (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  91.203.238.218       anywhere             ctorigdstport 8880 ctdir ORIGINAL
DROP       tcp  --  anywhere             anywhere             ctorigdstport 8880 ctdir ORIGINAL
RETURN     all  --  anywhere             anywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment