关键词:
阿里云CentOS系统配置iptables防火墙
虽说阿里云推出了云盾服务,但是自己再加一层防火墙总归是更安全些,下面是我在阿里云vps上配置防火墙的过程,目前只配置INPUT。OUTPUT和FORWORD都是ACCEPT的规则
一、检查iptables服务状态
首先检查iptables服务的状态
[[email protected] ~]# service iptables status iptables: Firewall is not running.
说明iptables服务是有安装的,但是没有启动服务。
如果没有安装的话可以直接yum安装
yum install -y iptables
启动iptables
[[email protected] ~]# service iptables start iptables: Applying firewall rules: [ OK ]
看一下当前iptables的配置情况
[[email protected] ~]# iptables -L -n
二、清除默认的防火墙规则
#首先在清除前要将policy INPUT改成ACCEPT,表示接受一切请求。 #这个一定要先做,不然清空后可能会悲剧 iptables -P INPUT ACCEPT #清空默认所有规则 iptables -F #清空自定义的所有规则 iptables -X #计数器置0 iptables -Z
三、配置规则
#允许来自于lo接口的数据包 #如果没有此规则,你将不能通过127.0.0.1访问本地服务,例如ping 127.0.0.1 iptables -A INPUT -i lo -j ACCEPT #ssh端口22 iptables -A INPUT -p tcp --dport 22 -j ACCEPT #FTP端口21 iptables -A INPUT -p tcp --dport 21 -j ACCEPT #web服务端口80 iptables -A INPUT -p tcp --dport 80 -j ACCEP #tomcat iptables -A INPUT -p tcp --dport xxxx -j ACCEP #mysql iptables -A INPUT -p tcp --dport xxxx -j ACCEP #允许icmp包通过,也就是允许ping iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT #允许所有对外请求的返回包 #本机对外请求相当于OUTPUT,对于返回数据包必须接收啊,这相当于INPUT了 iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT #如果要添加内网ip信任(接受其所有TCP请求) iptables -A INPUT -p tcp -s 45.96.174.68 -j ACCEPT #过滤所有非以上规则的请求 iptables -P INPUT DROP
四、保存
首先iptables -L -n看一下配置是否正确。
没问题后,先不要急着保存,因为没保存只是当前有效,重启后就不生效,这样万一有什么问题,可以后台强制重启服务器恢复设置。
另外开一个ssh连接,确保可以登陆。
确保没问题之后保存
#保存 [[email protected] ~]# service iptables save #添加到自启动chkconfig [[email protected] ~]# chkconfig iptables on
centos6下防火墙(iptables)的配置方法详解
CentOS6系统是基于linux中的,它的防火墙其实就是iptables了。下面我来介绍在CentOS防火墙iptables的配置教程,希望此教程对各位朋友会有所帮助。iptables是与Linux内核集成的IP信息包过滤系统,其自带防火墙功能,我们在配置完服务... 查看详情
centos下配置iptables防火墙linuxnat(iptables)配置
CentOS下配置防火墙配置nat转发服务CentOS下配置iptables防火墙linuxNAT(iptables)配置CentOS下配置iptables 1,vim/etc/sysconfig/network 这里可以更改主机名称。NETWORKING=yesNETWORKING_IPV6=noHOSTNAME=BGI-TJ.localdomain GATEWAY 查看详情
(转)centos防火墙设置
1、安装iptables防火墙 怎么知道系统是否安装了iptables?执行iptables-V,如果显示如: iptablesv1.3.5 说明已经安装了iptables。 如果没有安装iptables需要先安装,执行: yuminstalliptables 在Linux中设置防火墙,以CentOS为... 查看详情
centos7安装配置iptables防火墙
...下如果不想用centos7自带的FIREwall而用7之前版本的iptables当防火墙,这样自动加端口比较方便,可以如下方式配置:一、关闭Firewall防火墙执行以下操作:systemctlstopfirewalld.servicesystemctldisablefirewalld.service二、安装iptables防火墙yuminstall... 查看详情
centos6.8防火墙配置(代码片段)
系统:CentOSrelease6.8(Final) 执行命令:#清除所有规则iptables-F#开放redis端口iptables-AINPUT-ptcp-mtcp--dport3379-jACCEPT#开放MySql端口iptables-AINPUT-ptcp-mtcp--dport3306-jACCEPT#开放WebServer端口iptables-AINPUT-ptcp-mtc 查看详情
centos初步学习记录iptables(代码片段)
...iptables中文名:IP信息包过滤系统,它是一个配置Linux内核防火墙的命令行工具,是netfilter项目的一部分。术语iptables也经常代指该内核级防火墙。iptables可以直接配置,也可以通过许多前端和图形界面配置。iptables用于ipv4,ip6table... 查看详情
centos7安装配置iptables防火墙
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/50779761CentOS7默认的防火墙不是iptables,而是firewalle.安装iptable iptable-service [plain] viewplain copy #先检查是否安装了iptables&n 查看详情
阿里云centos配置iptables防火墙
虽说阿里云推出了云盾服务,但是自己再加一层防火墙总归是更安全些,下面是我在阿里云vps上配置防火墙的过程,目前只配置INPUT。OUTPUT和FORWORD都是ACCEPT的规则一、检查iptables服务状态首先检查iptables服务的状态[[email protect... 查看详情
centos系统级别限制端口,如何设置?不包括iptables
...服务,诸如CentOS或RHEL的企业级Linux发行版包含内置的强大防火墙,它们默认的防火墙规则十分严格。因此,如果你安装了任何定制的服务(比如web服务器、NFS和Samba),那么它们的流量很有可能被防火墙规则阻塞。所以需要在防... 查看详情
centos切换为iptables防火墙并进行相关配置(代码片段)
CentOS切换为iptables防火墙切换到iptables首先应该关掉默认的firewalld,然后安装iptables服务。1、关闭firewall:servicefirewalldstopsystemctldisablefirewalld.service#禁止firewall开机启动2、安装iptables防火墙yuminstalliptables-services#安装3、编辑iptab 查看详情
centos安装iptables和iptables-services
参考技术A查看当前系统是否安装防火墙安装iptables安装iptables-services查看iptables现有规则防火墙是需要开启80端口,不然外网就不能访问到主机资源。开启相关规则的命令:保存配置,并重启: 查看详情
centos7.3下的一个iptables配置
centos7.3默认使用的防火墙应该是firewall,而不是iptables。而我们xxmj服务器使用的是iptables防火墙。所以,在配置防火墙之前,我们需要先关闭firewall,安装iptables。查看firewall的安装和启动状态[[email protected]~]#yumlistinstalledfirewall... 查看详情
centos配置iptables作为防火墙来替代默认的firewalld(代码片段)
...tables3.禁用firewalld服务4.编辑/etc/sysconfig/iptables文件来修改防火墙信息1.更新软件包sudoyumupdate出现如下信息代表已经更新到最新版,确保软件包更新到最新已加载插件:fastestmirror,langpacksLoadingmirrorspeedsfromcachedhostfileNopackagesm... 查看详情
centos7.3下的一个iptables配置
centos7.3默认使用的防火墙应该是firewall,而不是iptables。而我们如果想要再服务器上使用iptables防火墙,在配置防火墙之前,我们需要先关闭firewall,安装iptables。当前环境:[[email protected] ~]# cat /etc/redhat-release Ce... 查看详情
centos7关闭firewall安装iptables并配置
一、配置防火墙,开启80端口、3306端口CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。1、关闭firewall:systemctlstopfirewalld.service #停止firewallsystemctldisablefirewalld.service #禁止firewall开机启动 2、安装iptables... 查看详情
centos6.5虚拟机安装后,没有iptables配置文件
openstack环境里安装centos6.5系统的虚拟机,安装好后,发现没有/etc/syscofig/iptables防火墙配置文件。解决办法如下:[[email protected]~]#iptables-POUTPUTACCEPT[[email protected]~]#/etc/init.d/iptablessaveiptables:Savingfirew 查看详情
centos7的防火墙怎么开放端口
可以用iptables防火墙试试CentOS_6.5配置iptables防火墙策略#清除预设表filter中的所有规则链的规则iptables-F#清除预设表filter中使用者自定链中的规则iptables-X#保存iptables配置serviceiptablessave#重启iptables服务serviceiptablesrestart#查看iptables规... 查看详情
转载centos7关闭firewall防火墙指令以及更换安装iptables并配置
转载连接 http://ashui.net/archives/2015/943.html 一、配置防火墙,开启80端口、3306端口CentOS7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。1、关闭firewall:systemctlstopfirewalld.service#停止firewallsystemctldisablefirewalld 查看详情