一、Linux开放端口:

1. CentOS7.x/RedHat7.x  , 参考 CentOS7使用firewalld打开关闭防火墙与端口

1、firewalld的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld 
开机禁用  : systemctl disable firewalld
开机启用  : systemctl enable firewalld
 
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

3.配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息:  firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
那怎么开启一个端口呢
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp
删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent

2. CentOS6.x/RedHat6.x ,  参考 Centos6.5 防火墙开放端口

1. 查看防火墙当前设置
/etc/init.d/iptables status
或者 service iptables status 2. 配置防火墙策略(root权限)
比如我要开放22/80/3306三个端口,可以在/etc/sysconfig/iptables文件中添加三行信息,如下:
vi /etc/sysconfig/iptables 内容修改成如下:
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT -A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT -A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT 保存,退出 3. 重启防火墙
service iptables restart 4. 开放一个范围的端口 , 比如开放3000到5000的端口。
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3000:5000 -j ACCEPT 5. 重启或关闭防火墙两种方式
5.1 系统重启后生效。开机自启动,或者自动关闭。
开启: chkconfig iptables on
关闭: chkconfig iptables off
5.2 即时生效,系统重启后失效
开启: service iptables start
关闭: service iptables stop

Windows开放端口:

参考 win7/win8设置防火墙端口开放及检测开放端口

windows10开放端口:

Win+R键调出 运行--》输入control,快速打开控制面板:

点击系统和安全

点击Windows Defender 防火墙

点击高级设置

点击”入站规则“,然后点击右侧的”新建规则“。

然后点击”端口“。

接着填写开放的端口号。

接着直接点击下一步,再下一步,最后完成。

完成之后,可以用telnet测试端口是否开放。telnet 127.0.0.1 8086,如果出现下图的界面就说明该端口已经开放。

windows、Linux 开放端口的更多相关文章

  1. linux开放端口关闭防火墙

    linux开放端口关闭防火墙 systemctl status firewalld查看当前防火墙状态. 开启防火墙      systemctl start firewalld开放指定端口       ...

  2. Linux 开放端口

    安装iptables 一般情况下,ubuntu安装好的时候,iptables会被安装上,没有安装上也没啥,一条命令就可以安装了. apt-get install iptables 安装好了之后就可以添 ...

  3. Linux开放端口

    开放端口8081 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT 重启端口服务 ser ...

  4. linux开放端口并测试

    开放端口操作 开放端口 先开启防火墙(才能用开启端口的命令) systemctl start firewalld.service 开放端口 firewall-cmd --zone=public --a ...

  5. Centos/linux开放端口

    在linux上部署tomcat发现外部无法访问可以通过两种方式解决: 1.关闭防火墙 service iptables stop(不推荐) 2.修改相关文件,开放需要开放的端口 (1)通过命令vi / ...

  6. windows和Linux查看端口占用进程并关闭

    Windows: 以端口8080为例: 1.查找对应的端口占用的进程:netstat  -aon|findstr  "8080"    ,找到占用8080端口对应的程序的PID号: ...

  7. linux IPtable防火墙 禁止和开放端口(转)

    linux IPtable防火墙 禁止和开放端口源:http://hi.baidu.com/zplllm/item/f910cb26b621db57c38d5983评: 1.关闭所有的 INPUT F ...

  8. CentOS/Linux开放某些端口

    CentOS/Linux开放某些端口 CentOS/Linux 装载系统的时候只开启了少数端口如22,80(有些连80都没有开放)等. 结果再装完Nginx+PHP+MySQL 后不能访问网站. 当然 ...

  9. Linux中检查本地系统上的开放端口列表的方法

    在 Linux 中很少有用于此目的的实用程序.然而,我提供了四个最重要的 Linux 命令来检查这一点. 你可以使用以下四个命令来完成这个工作.这些命令是非常出名的并被 Linux 管理员广泛使用.n ...

随机推荐

  1. PAT 天梯赛 L2-003. 月饼 【贪心】

    题目链接 https://www.patest.cn/contests/gplt/L2-003 思路 用贪心思路 最后注意一下 总售价有可能是浮点数 AC代码 #include <cstdio& ...

  2. 【LeetCode】【动态规划】Generate Parentheses(括号匹配问题)

    描述 Given n pairs of parentheses, write a function to generate all combinations of well-formed parent ...

  3. 高性能js之数据访问性能

    js中si中基本数据访问: 直接量, 变量, 数组项, 对象成员 性能问题: 首先要理解作用域链的基本概念,例如,当一个函数被创建时,就会产生一个激活对象(AO对象),AO对象中存储了该函数中所有的属 ...

  4. Nginx/Apache下如何禁止指定目录运行PHP脚本

    下面和大家一起分享下如何在Apache和Nginx禁止上传目录里PHP的执行权限. Apache下禁止指定目录运行PHP脚本 在虚拟主机配置文件中增加php_flag engine off指令即可,配 ...

  5. Shiro-Permissions 对权限的深入理解

    单个权限 query单个资源多个权限 user:query user:add 多值 user:query,add单个资源所有权限 user:query,add,update,delete user:* ...

  6. 分享知识-快乐自己:Liunx—Maven 部署步骤

    第一步: 点我下载 Liunx—Maven Linux命令下载:wget [下载文件存放路径]   [下载文件地址] 第二步: 上传 Maven 并解压到 指定的目录:(上传方式 xftp 或 rz ...

  7. Oracle忘记用户名密码

    一.oracle 11g登录服务开启 成功安装Oracle 11g后,共有7个服务,这七个服务的含义分别为:1. Oracle ORCL VSS Writer Service:Oracle卷映射拷贝写 ...

  8. 【leetcode刷题笔记】Recover Binary Search Tree

    Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing ...

  9. APIO2017商旅

    传送门(PDF) 题目大意:有$N$个点,$M$条有向边,$K$种物品,在不同的点可以用不同的价格买入或卖出某一种商品. 任意时刻至多持有一种物品,不能在同一个点先买再卖,求收益与长度之比最大的点数$ ...

  10. LeetCode 510. Inorder Successor in BST II

    原题链接在这里:https://leetcode.com/problems/inorder-successor-in-bst-ii/ 题目: Given a binary search tree an ...