Add an iptables rule to block connections to the web server. Enter the iptables commands you used to add this rule to your firewall and explain it. (Kali Linux or CentOS)
To block a specific service like a web server using iptables, we need to specify a rule for dropping all packets coming to that port.
A web server uses port 80 for HTTP. On CentOS, to block connections to the web server, we can define a INPUT iptable rule like below:
sudo iptables -A INPUT -p tcp --dport 80 -j DROP
To make this change permanent (survive iptables service restart or a system reboot), additionally run:
sudo iptables-save > /etc/sysconfig/iptables
This will block all incoming traffic to the web server (assuming its only serving as HTTP, for HTTPS we've to define an additional rule with port 443).
Get Answers For Free
Most questions answered within 1 hours.