CentOS 7 iptables与firewalld

1.默认Centos 7中已取消iptables而改用firewalld,而实际上iptables与firewalld只是单纯的配置规则的客户端工具而真正起到防火墙包过滤/转发的功能是内核netfilter模块

2.启用iptables关闭firewalld

#systemctl stop firewalld
#systemctl disable firewalld
#yum install iptables-services #安装此包的作用在于生成iptables.service服务文件以及生成/etc/sysconfig/iptables规则配置保存文件等

3.添加规则并保存到/etc/sysconfig/iptables

# iptables -t filter -A INPUT -p tcp -m state --state NEW -m tcp --dport 8082 -j ACCEPT
# iptables-save > /etc/sysconfig/iptables #确保系统重启后,手动配置的规则写到配置文件中依然生效
# systemctl restart iptables

4.iptables服务配置中依赖于/etc/sysconfig/iptables

[Unit]
Description=IPv4 firewall with iptables
Before=ip6tables.service
After=syslog.target
AssertPathExists=/etc/sysconfig/iptables

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/iptables/iptables.init start
ExecReload=/usr/libexec/iptables/iptables.init reload
ExecStop=/usr/libexec/iptables/iptables.init stop
Environment=BOOTUP=serial
Environment=CONSOLETYPE=serial
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=basic.target

 

posted @ 2018-11-16 20:27  2240930501  阅读(579)  评论(0编辑  收藏  举报