2

I have Debian 7, and I want to block all websites in my computer, unless my email, using IPTABLES or others firewall.

How can I block all website, include http and https too.

How can I do this?

4
iptables -I OUTPUT -p tcp -m tcp --dport 443 -j REJECT --reject-with icmp-port-unreachable
iptables -I OUTPUT -p tcp -m tcp --dport 80 -j REJECT --reject-with icmp-port-unreachable
iptables -I OUTPUT -p tcp -m tcp -d youremailsiteIP/32 --dport 80 -j ACCEPT
iptables -I OUTPUT -p tcp -m tcp -d youremailsiteIP/32 --dport 443 -j ACCEPT

where youremailsiteIP is the IP address of your mail site

  • this iptables will block https too? – Vitor Mazuco Jun 25 '15 at 23:41
  • 1
    Yes, but... it doesn't really block http or https. It blocks the ports that they most commonly use: http - port 80, and https - port 443. However, some sites use non-standard ports, and those will not be blocked by the above. For example: http://example.com:8080/ or https://example.com:8443/ – Mel Jun 26 '15 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.