firewall,iptablse和selinux防火墙

来源:互联网 发布:数据魔方是什么 编辑:程序博客网 时间:2024/05/17 16:53

CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。

firewall

firewall能够允许哪些服务可用,那些端口可用.... 属于更高一层的防火墙。
firewall的底层是使用iptables进行数据过滤,建立在iptables之上。

firewall是动态防火墙,使用了D-BUS方式,修改配置不会破坏已有的数据链接。

关闭firewall

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

iptables

iptables用于过滤数据包,属于网络层防火墙.

在设置iptables后需要重启iptables,会重新加载防火墙模块,而模块的装载将会破坏状态防火墙和确立的连接。会破坏已经对外提供数据链接的程序。可能需要重启程序。

iptables防火墙

yum install iptables-services #安装iptables
vi /etc/sysconfig/iptables #编辑iptables防火墙配置文件
[plain] view plain copy
 print?
  1. # Firewall configuration written by system-config-firewall  
  2. # Manual customization of this file is not recommended.  
  3. *filter  
  4. :INPUT ACCEPT [0:0]  
  5. :FORWARD ACCEPT [0:0]  
  6. :OUTPUT ACCEPT [0:0]  
  7. -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT  
  8. -A INPUT -p icmp -j ACCEPT  
  9. -A INPUT -i lo -j ACCEPT  
  10. -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT  
  11. -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT  
  12. -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT  
  13. -A INPUT -j REJECT --reject-with icmp-host-prohibited  
  14. -A FORWARD -j REJECT --reject-with icmp-host-prohibited  
  15. COMMIT  
  16. :wq! #保存退出  
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动

SELinux

SELinux(Security-Enhanced Linux) 是美国国家安全局(NSA)对于强制访问控制的实现,是 Linux历史上最杰出的新安全子系统。它不是用来防火墙设置的。但它对Linux系统的安全很有用。Linux内核(Kernel)从2.6就有了SELinux。

SELinux是一种基于 域-类型 模型(domain-type)的强制访问控制(MAC)安全系统,它由NSA编写并设计成内核模块包含到内核中,相应的某些安全相关的应用也被打了SELinux的补丁,最后还有一个相应的安全策略。任何程序对其资源享有完全的控制权。假设某个程序打算把含有潜在重要信息的文件扔到/tmp目录下,那么在DAC情况下没人能阻止他。SELinux提供了比传统的UNⅨ权限更好的访问控制。

关闭SELINUX

vi /etc/selinux/config
[plain] view plain copy
 print?
  1. #SELINUX=enforcing #注释掉  
  2. #SELINUXTYPE=targeted #注释掉  
  3. SELINUX=disabled #增加  
:wq! #保存退出
setenforce 0 #使配置立即生效

原文链接

http://blog.csdn.net/geng823/article/details/41806205

参考链接

http://www.111cn.net/sys/CentOS/63646.htm

http://www.tuicool.com/articles/qYnuMj

原创粉丝点击