centos防火墙设置
来源:互联网 发布:网络搬砖项目 编辑:程序博客网 时间:2024/06/05 23:06
centos防火墙设置
CentOS 7
CentOS 7.0默认使用的是firewall作为防火墙
firewall-cmd –state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
firewall-cmd –list-ports #查看已经开放的端口
firewall-cmd –zone=public –add-port=80/tcp –permanent #开启端口
命令含义:
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
firewall-cmd –reload #重启firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
使用iptable
安装
yum -y install iptables-services
编辑防火墙配置文件
vi /etc/sysconfig/iptables# sampleconfiguration for iptables service# you can edit thismanually or use system-config-firewall# please do not askus to add additional ports/services to this default configuration*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT[0:0]:OUTPUT ACCEPT[0:0]-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT-A INPUT -p icmp -jACCEPT-A INPUT -i lo -jACCEPT-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT-A INPUT -j REJECT--reject-with icmp-host-prohibited-A FORWARD -jREJECT --reject-with icmp-host-prohibitedCOMMIT:wq! #保存退出
这里使用80和8080端口为例。*部分一般添加到“-A INPUT -p tcp -m state –state NEW -m tcp–dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行,否则防火墙重启后不生效。
systemctl restart iptables.service #重启防火墙
systemctl enable iptables.service #开机启动
systemctl disable iptables.service #禁止开机启动
最后
vi /etc/selinux/config注释下面两行:#SELINUX=enforcing#SELINUXTYPE=targetedsetenforce 0
- CentOS调整防火墙设置
- Linux Centos防火墙设置
- CentOS 5 防火墙设置
- Centos 防火墙设置
- Centos http 防火墙设置
- centos防火墙设置
- centos iptables防火墙设置
- CentOS 设置防火墙端口
- CentOS 防火墙设置
- centos 防火墙设置
- Centos防火墙设置
- centOS 防火墙详细设置
- centos iptables 防火墙设置
- CentOS 防火墙设置
- CentOS 7.0防火墙设置
- centos防火墙设置
- centos防火墙设置
- centos设置防火墙
- 7-JavaScript设计模式——桥接模式
- 闪回技术概念+闪回技术的形式
- Perl 入门 之 基础类型
- PHP jQuery+Ajax结合写批量删除功能
- mongodb,redis,mysql 简要对比
- centos防火墙设置
- 解读thchs30/s5/run.sh的主要步骤
- app开发过程中有关耗电注意事项
- 扩展欧几里得算法
- mysql group by 对多个字段进行分组
- Gson解析出现类似错误,com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_AR
- Shell脚本——提取目录名
- gitignore
- iphone屏幕尺寸总结