CentOS 6内置的防火墙为iptables,Cent OS7,内置的防火墙则是firewalld

iptables 防火墙设置

1.打开/关闭/重启防火墙

#开启防火墙(重启后永久生效):
chkconfig iptables on #关闭防火墙(重启后永久生效):
chkconfig iptables off #开启防火墙(即时生效,重启后失效):
service iptables start #关闭防火墙(即时生效,重启后失效):
service iptables stop #重启防火墙:
service iptables restartd

2.查看防火墙打开的端口

此处以开放8080端口为例:

(1)开放端口

iptables -A INPUT -p tcp --dport 1024 -j ACCEPT

(2)保存并生效

/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart

4.开放指定范围的端口

例如开放1024-10240之间的所有端口:

iptables -A INPUT -p tcp --dport 1024:10240 -j ACCEPT

firewalld防火墙设置

1.查看防火墙状态

systemctl status firewalld

此处如果提示firewalld.service could not be found.则说明你的系统没有装防火墙,则不需要设置。

2.开放指定端口

此处以开放1024端口为例:

firewall-cmd --zone=public --add-port=1024/tcp --permanent

–permanent参数表示永久生效,没有此参数重启后失效。

3.重启防火墙

#重启firewall
firewall-cmd --reload #停止firewall
systemctl stop firewalld.service #禁止firewall开机启动
systemctl disable firewalld.service #重启firewall
firewall-cmd --reload #停止firewall
systemctl stop firewalld.service #禁止firewall开机启动
systemctl disable firewalld.service #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
1
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
firewall-cmd --state

Cent OS防火墙配置端口开放的更多相关文章

  1. VMware NAT模式 Cent OS IP配置

    1:首先VMware 桥接模式 CentOS ip 配置,关键点,ip的网关和DNS1设置成宿主机的网关和DNS 原理:桥接的模式就是通过物理网卡实现的. 2:以图展示VMware NAT模式 Cen ...

  2. 二、cent OS安装配置tomcat

    下载tomcat的tar包http://tomcat.apache.org/download-80.cgi 确保安装前已经安装JDKjava -version如果没有安装可以参考上一篇文章:http: ...

  3. 一、cent OS安装配置JDK

    到oracle官网下载JDKhttp://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html 在cent OS ...

  4. 五、cent OS防火墙常用命令

    查看防火墙开闭状态systemctl status firewalld 开启防火墙systemctl start firewalld 关闭防火墙systemctl stop firewalld 查看已 ...

  5. linux centos7 防火墙及端口开放相关命令

    一.防火墙相关命令 1.查看防火墙状态 : systemctl status firewalld.service 注:active是绿的running表示防火墙开启 2.关闭防火墙 :systemct ...

  6. 【阿里云配置端口开放】使用 iptables

    要知道: 1.目前(16年-12-10)阿里云主机只要有服务开启,所有端口是默认开启的.这样很不好,安全做法是,需要开启外网端口时,由开发人员去配置. 2.想要开放端口,就需要使用iptables命令 ...

  7. CentOS7使用firewalld防火墙配置端口

    安装启用firewalld防火墙 CentOS7默认的防火墙是firewalld 如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装 firewalld ...

  8. windows防火墙设置端口开放技巧

    选择“打开或者关闭windows防火墙”把防火墙打开,然后选择“高级设置”,选择“创建规则”来指定端口.(这里也可以在“入站规则”里选择已经存在的端口.) 指定ip开放3389端口 某新服务器,开放8 ...

  9. 四、cent OS安装配置mysql

    下载mysql的repo源wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 安装mysql-community-r ...

随机推荐

  1. 模板—tarjan缩点

    void tarjan(int x) { dfn[x]=++cnt;low[x]=cnt; vi[x]=; stack[++top]=x; for(rint i=f(x);i;i=n(i)) if(! ...

  2. 什么是CGI、FastCGI、PHP-CGI、PHP-FPM、Spawn-FCGI?

    https://mp.weixin.qq.com/s/Co1LxS2h_ILh9syOmshjZg 什么是CGI CGI全称是“公共网关接口”(Common Gateway Interface),HT ...

  3. 解决TortoiseSVN中out of date问题的一个方法

    http://blog.csdn.net/freefalcon/article/details/645058 从去年开始,公司的代码管理从CVS转向了subvsersion,后者确实是前者的一个飞跃, ...

  4. python 多线程,tthread模块比较底层,而threading模块是对thread做了一些包装,multithreading

    Python多线程详解 2016/05/10 · 基础知识 · 1 评论· 多线程 分享到:20 本文作者: 伯乐在线 - 王海波 .未经作者许可,禁止转载!欢迎加入伯乐在线 专栏作者. 1.多线程的 ...

  5. 基于thinkphp实现根据用户ip判断地理位置并提供对应天气信息的应用

    https://blog.csdn.net/MyCodeDream/article/details/46706469 我们都知道,在很多的网站都提供了给用户提供天气预报的功能,有时会发现,用户即使不输 ...

  6. pip安装软件包报Could not fetch URL

    报这个错误的原因是python.org已经不支持TLSv1.0和TLSv1.1了.更新pip可以解决这个问题,但是你不能用命令 pip install --upgrade pip 做更新,因为TLS证 ...

  7. java接口的使用

    格式:public class SubImpl  extends Super  implements IA,IB 接口可以多继承,但是只能继承接口,不能继承类. 实现接口(支持多实现) [修饰符] c ...

  8. centOS 重启 php-fpm

     ps axo pid,%cpu,%mem,comm |grep php-fpm ps aux | grep php-fpm pkill -9 php-fpm /etc/init.d/php-fpm ...

  9. 手机web页面调用手机QQ实现在线聊天的效果

    html代码如下: <a href="javascript:;" onclick="chatQQ()">QQ咨询</a> js代码如下: ...

  10. 浅谈使用spring security中的BCryptPasswordEncoder方法对密码进行加密与密码匹配

    浅谈使用springsecurity中的BCryptPasswordEncoder方法对密码进行加密(encode)与密码匹配(matches) spring security中的BCryptPass ...