实质:防火墙策略(网络包的出和入)管理工具html
firewall和iptables相关操做,两者只能选择之一。
关于二者的区别:http://www.javashuo.com/article/p-yfsclvas-db.htmllinux
防火墙概述
防火墙:控制内网和外网之间的数据流通centos
一个条目为一个规则,多个规则组合在一块儿造成规则链网络
policytcp
- ACCEPT
- REJECT(我知道你来找我,可是我拒绝;你ping我,我会应答:目的端口不可达)
- LOG(记录)
- DROP(我知道你来了,可是我伪装不在;你无法判断我在不在)
chain(规则链)中数据处理位置工具
- INPUT
- OUTPUT
- PREROUTING
- POSTROUTING
- FORWORD

centos
firewall
- 状态:firewall-cmd --state
- 启动:systemctl start firewalld
- 中止:systemctl stop firewalld
- 重启:systemctl restart firewalld
- 禁止开机启动:systemctl disable firewalld
- 容许开机启动:systemctl enable firewalld
iptables
- 查看iptables状态:systemctl status iptables
- 启、停、重启:systemctl start/stop/restart iptables
- 查看已有规则:iptables -L
- 添加规则
- 直接编辑 /etc/sysconfig/iptables:-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT(开放80端口),编辑后重启
- iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT(开放22端口)
debain
firewall
- 安装:apt-get install firewalld
- 状态:firewall-cmd --state
- 启动:systemctl start firewalld
- 中止:systemctl stop firewalld
- 重启:systemctl restart firewalld
- 禁止开机启动:systemctl disable firewalld
- 容许开机启动:systemctl enable firewalld
iptables待续。。。
有用的博客:spa
http://www.javashuo.com/article/p-gzsdxtce-em.html.net
https://havee.me/linux/2015-01/using-firewalls-on-centos-7.htmlrest