关闭防火墙

  1. CentOS 7、RedHat 7 之前的 Linux 发行版防火墙开启和关闭( iptables ):

    • 即时生效,重启失效
    #开启
    service iptables start
    #关闭
    service iptables stop
    • 重启生效
    chkconfig iptables on
    #关闭
    chkconfig iptables off
  2. CentOS 7、RedHat 7 之后的 Linux 发行版防火墙开启和关闭( firewall )

    systemctl stop firewalld.service

开放端口

  1. CentOS 7、RedHat 7 之前的 Linux 发行版开放端口:

     #查看开放的端口列表
    firewall-cmd --list-ports #命令方式开放5212端口命令
    #开启5212端口接收数据
    /sbin/iptables -I INPUT -p tcp --dport 5212 -j ACCEPT #开启5212端口发送数据
    /sbin/iptables -I OUTPUT -p tcp --dport 5212 -j ACCEPT #保存配置
    /etc/rc.d/init.d/iptables save #重启防火墙服务
    /etc/rc.d/init.d/iptables restart #查看是否开启成功
    /etc/init.d/iptables status
  2. CentOS 7、RedHat 7 之后的 Linux 发行版开放端口:

    firewall-cmd --zone=public --add-port=5121/tcp --permanent
    # --zone 作用域
    # --add-port=5121/tcp 添加端口,格式为:端口/通讯协议
    # --permanent 永久生效,没有此参数重启后失效
    firewall-cmd --reload

使用iptables

  1. iptables 的安装
  • 系统默认使用 firewall 作为防火墙,把他停止和屏蔽,并且装一个iptable【CentOs 7 】

    systemctl stop firewalld
    systemctl mask firewalld
    yum install -y iptables
    yum install iptables-services
  • 升级iptables

    yum update iptables
    yum update iptables-services
  • 解除禁止 iptables 服务

    systemctl enable iptables
  • 开启服务

    systemctl start iptables.service
  • 配置 /etc/sysconfig 下的 iptables 文件[vim /etc/sysconfig/iptables]

    -A INPUT -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT
  • 重启防火墙使配置生效

    systemctl restart iptables.service
    
    
  • 设置防火墙为开机启动

    systemctl enable iptabls.service
  • 检查是否安装了 iptables

    service iptables status
  • 其它命令

    systemctl start iptables //开启/暂停服务
    systemctl stop iptables // systemctl disable iptables //禁止/解除禁止 iptables 服务
    systemctl enable iptables

转:https://www.cnblogs.com/jjxhp/p/11111898.html

参考:https://www.cnblogs.com/marso/archive/2018/01/06/8214927.html

(linux笔记)开放防火墙端口的更多相关文章

  1. linux - centos7 开放防火墙端口的新方式

    CentOS 升级到7之后,发现无法使用iptables控制Linuxs的端口, google之后发现Centos 7使用firewalld代替了原来的iptables. 下面记录如何使用firewa ...

  2. Linux下开放防火墙端口

    方法一:1.vi /etc/sysconfig/iptables 2.-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEP ...

  3. linux 安装禅道 和 CentOS 7 开放防火墙端口 命令

    linux 安装禅道链接:  https://www.cnblogs.com/maohuidong/p/9750202.html CentOS 7 开放防火墙端口 命令 链接:https://www. ...

  4. Linux 7.x 防火墙&端口

    Linux 7.x 防火墙&端口 查看当前防火墙的状态: # firewall-cmd --state 也可以使用指令:systemctl status firewall.service 启动 ...

  5. CentOS 7 开放防火墙端口

    我:最近在使 CentOS 7时发现在本地不能访问linux上8080端口,以上是我的操作,修改后访问成功 CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现 ...

  6. Linux系统 开通防火墙端口

    Redhat 7内核 Linux系统  开通防火墙端口 使用systemctl 1.查看防火墙状态,root用户登录,执行命令systemctl status firewalld 2.开启防火墙:sy ...

  7. CentOS 7 开放防火墙端口命令

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  8. CentOS 7 开放防火墙端口 命令(转载)

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  9. linux suse系统防火墙端口开放配置

    1.切换到root用户下 2.进入到/etc/sysconfig/SuSEfirewall2 3.修改FW_SERVICES_EXT_TCP=" 22 80 8080 8081 8082 8 ...

  10. 【linux】如何开放防火墙端口

    linux默认大部分端口的是关闭的.而我们在开发.部署环境时,需要用到大量的服务,如mysql.tomcat.redis.zk等,需要开放指定的端口号. 以mysql端口3306为例 首先编辑服务器的 ...

随机推荐

  1. Windchill_二次开发新手入门常用的API

    Windchill_二次开发新手入门常用的API 1.根据零件名称/编码 得到该零件 wt.clients.prodmgmt.WTPartHelper.findPartByName(name) ;   ...

  2. node 版本管理器 nvs

    node 总是在不断的升级,以前老项目在运行时可能会报错 我遇到了一个 PostCSS received undefined instead of CSS string 查了下可能是node-sass ...

  3. Jquery 简单实现demo

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 重新安装office原版本没卸载干净

    先在设置--卸载界面确保已经卸载 在键盘上按"win+R",在运行窗口里面输入"regedit",回车 ,进入注册表编辑器 找到products 删除与offi ...

  5. (0709) Linux-命令(scp,tar) zip

    (1) scp .bashrc root@192.168.1.6:vnc://cfy-hp-notebook-pc.local (2) tar -czvf a.tar.gz b            ...

  6. 地址重写了,只是ip 没转发,应该是9999那个才对,rewrite /sbgl/(.*) http://127.0.0.1:9999/$1 permanent;,这样,

    记录想nginx搞路径重写的失败历程. 1.想将从nginx发出的127.0.0.1:80 请求过来的带sbgl的字眼去掉,然后,代理为127.0.0.1:9999, 所以我就百度出这个  这个  r ...

  7. AWT+Swing实现百度图像识别

    1准备 1.1在百度智能云中创建自己的应用,得到API Key和Secret Key 1.2maven导入SDK依赖 2源码 import java.net.URLEncoder; /** * 植物识 ...

  8. [笔记] Android开发中的gradle是什么?

    gradle是什么? 先看下文档中的介绍   https://docs.gradle.org/current/userguide/what_is_gradle.html Gradle is an op ...

  9. twenty-three

    Vue(用于构建用户界面的前端框架) Vue框架的特性,主要有 ① 数据驱动试图 ②双向数据绑定 js数据的变化,会被自动渲染到页面上 页面上表单采集的数据发生变化的时候,会被vue自动获取到,并更新 ...

  10. ESP_IDF中使用TFT_eSPI库驱动ST7789V

    前言: 想学习创建好看的菜单界面很久了,寒假在家正好有时间,手中恰好有一块ST7789的tft屏幕,正好拿来练练手. Step 1: 在github中找到TFT_eSPI库(网址:docs · mas ...