How to Close/Restrict a Port on a Linux Server Using CSF and Iptables
Using CSF (ConfigServer Security & Firewall)
- Block a Specific Port
nano /etc/csf/csf.conf
Remove the port you wish to close (e.g., 8080) from TCP_IN and TCP_OUT.
- Restart CSF to Apply Changes
csf -r
Using Iptables
- Delete Rule for a Specific Port
iptables -D INPUT -p tcp --dport 8080 -j ACCEPT
- Save Changes
sudo netfilter-persistent save
If you need further assistance, please reach out to our support team at support@ipserverone.com.