CentOS
发布时间:2022-04-02 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS 7.0 添加防火墙,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
概述
操作系统环境:CentOS Linux release 7.0.1406(Cor
E) 64位 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。 1、关闭firewall: systemctl stop firewalld.
service #停止firewall systemctl disable firewalld.
service #禁止firewa
操作系统环境:CentOSLinux release 7.0.1406(CorE) 64位
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。
1、关闭firewall:
sy
stemctl stop firewalld.
service #停止firewall
sy
stemctl disable firewalld.
service #
禁止firewall开机启动
firewall-cmd --state #查看
默认防火墙状态(
关闭后
显示notrunning,开启后
显示running)
2、iptables防火墙(这里iptables已经安装,下面进行配置)
vi/etc/syscon
fig/iptables #编辑防火墙
配置文件
# samplecon
figuration for iptables
service
# you can edit thi
smanually or use sy
stem-con
fig-firewall
# please do not askus to add additional ports/
services to this default con
figuration
*filter
:INPUT ACCEPT [0:0]
:FOR
WARD 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 RE
jeCT--re
ject-with icmp-host-prohibited
-A FOR
WARD -jRE
jeCT --re
ject-with icmp-host-prohibited
COMMIT
:wq! #保存
退出
备注:这里使用80和8080端口为例。***部分一般添加到“-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT”行的上面或者下面,切记不要添加到最后一行,否则防火墙重启后不生效。
3.重启生效
sy
stemctlrestart iptable
s.service #最后重启防火墙使配置生效
sy
stemctlenable iptable
s.service #设置防火墙开机启动
全文完..........
大佬总结
以上是大佬教程为你收集整理的CentOS 7.0 添加防火墙全部内容,希望文章能够帮你解决CentOS 7.0 添加防火墙所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。