一:centos7下/etc/sysconfig/目录没有iptables问题
因为没有安装iptables,在新买的centos7服务器中想打开防火墙,采用传统centos6的方式用service iptables restart/stop/status;
解决方案:关闭firewall:
[root@localhost ~]# systemctl stop firewalld.service #停止firewall
[root@localhost ~]# systemctl disable firewalld.service #禁止firewall开机启动
--安装安装iptables防火墙
[root@localhost ~]# yum install iptables-services #安装
--启动
systemctl start iptables.service
iptable的用法
--开放特定的端口,以80为例
iptables -A INPUT -p tcp --dport 80 -j ACCEP
iptables可以方便的配置多个端口。其中根据端口的连续性,又可分为连续端口配置和不连续端口配置。
连续端口配置
-A INPUT -p tcp –dport 21:25 -j DROP
使用multiport参数配置不连续端口
-A INPUT -p tcp -m multiport –dport 21:25,135:139 -j DROP
--重启
systemctl restart iptables.service
--设置开机自启动
systemctl enable iptables.service