Iptables Block outbound url in Linux

Gokul K
1 min readFeb 6, 2024

--

iptables is a command-line firewall utility that uses policy chains to allow or block traffic. When a connection tries to establish itself on your system, iptables looks for a rule in its list to match it to. If it doesn’t find one, it resorts to the default action.

For this in particular, you’ll need a kernel compiled with Netfilter “String match support” enabled.

iptables -A OUTPUT -p tcp -m string --string "/webnus.net/plugin-api/verify" --algo kmp -j REJECT --reject-with tcp-reset
iptables -A OUTPUT -p tcp -m string --string "/webnus.net/addons-api/verify" --algo kmp -j REJECT --reject-with tcp-reset

Alternatively and for extra cookie points, you can always block all outgoing connections and whitelist only the ones are ok with you.

--

--

Gokul K
Gokul K

Written by Gokul K

A startup Guy. Loves to solve problems. DevSecOps Engineer. #AWScertified #kubernetescertified #terraformcertified credly: https://www.credly.com/users/gokul.k

No responses yet