A brief analysis of the usage of CentOS firewall
- 2020-05-17 07:12:49
- OfStack
This article illustrates the use of the CentOS firewall as an example. I will share it with you for your reference as follows:
Close:
/etc/init.d/iptables stop
Open:
/etc/init.d/iptables start
Resume:
/etc/init.d/iptables restart
To view:
/etc/init.d/iptables status
Save:
/etc/init.d/iptables save
Open port 8080:
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
Delete - D
The rule will block packets from a particular IP range
# iptables -t filter -A INPUT -s 123.456.789.0/24 -j DROP
It is also very easy to block all packets going to the attacker's IP address. This command is slightly different:
# iptables -t filter -A OUTPUT -d 123.456.789.0/24 -j DROP
I hope this article has helped you with your CentOS server maintenance.