0

Let's say I want to disable HTTP(S) on my computer.

sudo iptables -A INPUT -p tcp --destination-port 80 -j DROP
sudo iptables -A INPUT -p tcp --destination-port 443 -j DROP

Why can I still browse webpages after executing these commands? I have been trying out various iptables commands, but not a single one has shown any effect so far. (my final goal is redirecting packages for a certain port)

I tried service iptables start, but got the message Failed to start iptables.service: Unit iptables.service not found. But shouldn't iptables run by default?

head /proc/sys/net/ipv4/ip_forward says 1.

edit. Ok, sorry: the error actually lies somewhere else. Please feel free to look into my other question.

3
  • 2
    Is ipv6 enabled? Sep 16, 2016 at 11:46
  • Are you trying to block your machine from making outbound connections to remote machines on ports tcp/80 and tcp/443? If so, you want to modify the OUTPUT chain, not the INPUT chain. Sep 16, 2016 at 11:48
  • Are you browsing pages on the computer that you entered the iptables commands on or are you browsing a remote computer ?
    – user9517
    Sep 16, 2016 at 11:53

1 Answer 1

2

You are blocking traffic in the INPUT chain, which is applied to IP packets coming towards your computer. The destination port here means the port on your computer. That port is random, selected by the OS when it opens the TCP socket to the remote server port 80 / 443.

When you browse other computer, packets traverse through the OUTPUT chain.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .