Centos7 iptables安装
Centos7 iptables安装
Centos7如何安装iptables?本教程以Centos7系统为例
本配置适用于centos7版本
先检查是否安装了iptables
Service iptables status

2.安装iptables
yum install -y iptables

3.升级iptables
yum update iptables

4.安装iptables-services
yum install iptables-services

禁用/停止自带的firewalld服务
#停止firewalld服务
systemctl stop firewalld
#禁用firewalld服务
systemctl mask firewalld

配置文件路径为:/etc/sysconfig/iptables
5.规则的写法:
iptables定义规则的方式比较复杂:
格式:
iptables [-t table] COMMAND chain CRETIRIA -j ACTION
-t table :3个filter nat mangle
COMMAND:定义如何对规则进行管理
chain:指定你接下来的规则到底是在哪个链上操作的,当定义策略的时候,是可以省略的
CRETIRIA:指定匹配标准
-j ACTION :指定如何进行处理
比如:不允许172.16.0.0/24的进行访问。
iptables -t filter -A INPUT -s 172.16.0.0/16 -p udp --dport 53 -j DROP
当然你如果想拒绝的更彻底:
比如:打开8080端口为例子。
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT