admin管理员组

文章数量:1403066

I'm doing the following exercise:

Launch a web server on TCP/8080 port on your target and use iptables to block incoming traffic on that port.

Starting from this iptables

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination   

What I did is:

# run web server on port 8080
sudo systemctl start apache2

# solution 1: drop the packet
sudo iptables -A INPUT -p tcp --dport 8080 -j DROP

DROP works: when I go to http://localhost:8080 in the browser, the connection times out.

# flush iptables
sudo iptables -F

# solution 2: reject the packet
sudo iptables -A INPUT -p tcp --dport 8080 -j REJECT

REJECT doesn't work: when I go to http://localhost:8080 in the browser, I can see the Apache2 default page. I was expecting to get the "port unreachable" error?

Thanks ahead for your help :)

本文标签: iptablesREJECT rule doen39t work but DROP does for dropping localhost8080 packetsStack Overflow