centos6+如何对外开放80,3306端口号或者其他端口号
1.查看防火墙对外开放了哪些端口
[root@hadoop110 ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
ACCEPT all -- 0.0.0.0/ 0.0.0.0/
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)
target prot opt source destination
2.centos6.0防火墙操作:
配置文件:/etc/sysconfig/iptables
开启某个端口号有两种方式:一种是命令方式,一种是修改配置文件方式
查看防火墙状态:chkconfig iptables --list
[root@hadoop110 ~]# chkconfig iptables --list
iptables :关闭 :关闭 :启用 :启用 :启用 :启用 :关闭
开启防火墙(重启后永久生效):chkconfig iptables on
关闭防火墙(重启后永久生效):chkconfig iptables off
[root@hadoop110 ~]# chkconfig iptables --list
iptables :关闭 :关闭 :启用 :启用 :启用 :启用 :关闭
[root@hadoop110 ~]# chkconfig iptables off
[root@hadoop110 ~]# chkconfig iptables --list
iptables :关闭 :关闭 :关闭 :关闭 :关闭 :关闭 :关闭
[root@hadoop110 ~]# chkconfig iptables on
[root@hadoop110 ~]# chkconfig iptables --list
iptables :关闭 :关闭 :启用 :启用 :启用 :启用 :关闭
[root@hadoop110 ~]#
开启防火墙(即时生效,重启后失效):service iptables start
关闭防火墙(即时生效,重启后失效):service iptables stop
重启防火墙:service iptables restart
查看开启的端口号
service iptables status
[root@hadoop110 ~]# service iptables status
\表格:filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
ACCEPT all -- 0.0.0.0/ 0.0.0.0/
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT)
num target prot opt source destination
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
3.开启某个端口号(如80端口号,命令方式)
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
[root@hadoop110 ~]# iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport -j ACCEPT
保存开启的端口号
service iptables save
[root@hadoop110 ~]# service iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
[root@hadoop110 ~]# iptables status
Bad argument `status'
Try `iptables -h' or 'iptables --help' for more information.
重新启动防火墙
service iptables restart
[root@hadoop110 ~]# service iptables restart
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:清除防火墙规则: [确定]
iptables:正在卸载模块: [确定]
iptables:应用防火墙规则: [确定]
查看开启的端口号
service iptables status
[root@hadoop110 ~]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
ACCEPT all -- 0.0.0.0/ 0.0.0.0/
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt: Chain FORWARD (policy ACCEPT)
num target prot opt source destination
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
开启某个范围的端口号(如18881~65534,命令方式)
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 18881:65534 -j ACCEPT
[root@hadoop110 ~]# iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport : -j ACCEPT
保存开启的端口号
service iptables save
[root@hadoop110 ~]# service iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables: [确定]
重新启动防火墙
service iptables restart
查看开启的端口号
service iptables status
[root@hadoop110 ~]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ tcp dpt:
ACCEPT all -- 0.0.0.0/ 0.0.0.0/ state RELATED,ESTABLISHED
ACCEPT icmp -- 0.0.0.0/ 0.0.0.0/
ACCEPT all -- 0.0.0.0/ 0.0.0.0/
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpt:
ACCEPT tcp -- 0.0.0.0/ 0.0.0.0/ state NEW tcp dpts:: Chain FORWARD (policy ACCEPT)
num target prot opt source destination
REJECT all -- 0.0.0.0/ 0.0.0.0/ reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
4.通过修改配置文件开启端口号(如80端口号)
vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
启动防火墙
service iptables restart
参数说明:
–A 参数就看成是添加一条规则
–p 指定是什么协议,我们常用的tcp 协议,当然也有udp,例如53端口的DNS
–dport 就是目标端口,当数据从外部进入服务器为目标端口
–j 就是指定是 ACCEPT -接收 或者 DROP 不接收
原文:https://blog.csdn.net/u014079773/article/details/79745819
centos6+如何对外开放80,3306端口号或者其他端口号的更多相关文章
- linux mysql 查看默认端口号和修改端口号
如何查看mysql 默认端口号和修改端口号 2015-03-19 17:42:18 1. 登录mysql [root@test /]# mysql -u root -p Enter password: ...
- 如何查看mysql 默认端口号和修改端口号
http://blog.itpub.net/26148431/viewspace-1466379/ 1,登录mysql 2,使用命令show global variables like 'port'; ...
- 查看mysql 默认端口号和修改端口号
1. 登录mysql mysql -u root -p //输入密码 2. 使用命令show global variables like 'port';查看端口号 mysql> show glo ...
- CentOS7查看开放端口命令及开放端口号
CentOS 7查看以开放端口命令:firewall-cmd —list-ports 查看端口是否开放命令:第一个方法就是使用lsof -i:端口号命令行,例如lsof -i:80.如果没有任何信息输 ...
- 登录MySQL非默认3306端口号的语句
这里登陆的是mysql3308端口号的数据库 mysql -P3308 -p用户名 -u密码
- Centos7 开放80,3306端口解决办法
所有扯iptables的文章都是扯淡!!! centos 7 默认防火墙由firewalld来管理!关iptables屁事! 以开放80端口为例,执行以下命令: 开放80端口:firewall-cmd ...
- SQL Server 端口号的使用
SQL Server 端口号的使用 服务器地址 逗号 端口号 服务器地址,端口号 xxx.xxx.xxx.xxx,0000 www.xxx.com,1533 (1533是SQL Server 的端 ...
- linux-sftp-指定端口号登录远程主机
sftp -oPort=60001 root@192.168.0.254 -o选项来指定端口号 -oPort=远程端口号
- 调试技巧--Windows端口号是否被占用
调试技巧--Windows端口号是否被占用 一.端口概念 10.0.0.0~10.255.255.255,172.16.0.0~172.16.255.255, 192.168.0.0~192.168. ...
随机推荐
- MongoDB简介及基础知识
MongoDB简介 一.MongDB是一个高性能,开源,无模式的文档型NosQL数据库.主要功能特性: 1.文件存储格式BSON(一种json的扩展) 2.模式自由,数据格式不受限了表的结构 3.支持 ...
- OpenGL顶点缓冲区对象
[OpenGL顶点缓冲区对象] 显示列表可以快速简单地优化立即模式(glBegin/glEnd)的代码.在最坏的情况下,显示列表的命令被预编译存到命令缓冲区中,然后发送给图形硬件.在最好的情况下,是编 ...
- Tensorflow学习(练习)—CPU训练模型
Mask R-CNN - Train on Shapes Dataset This notebook shows how to train Mask R-CNN on your own dataset ...
- 448. Find All Numbers Disappeared in an Array 寻找有界数组[1,n]中的缺失数
[抄题]: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice ...
- 性能优化之_android多线程
本文大纲为: 如何创建线程 线程间如何通讯 线程间如何安全的共享信息 一.线程的创建 Thread在run方法中执行具体事务,或者传入一个runnable对象,但是不能调用view控件的更新方法,但是 ...
- 如何安全退出已调用多个Activity的应用
对于单一Activity的应用来说,退出很简单,直接finish()即可.当然,也可以用killProcess()和System.exit()这样的方法. 但是,对于多Activity的应用来说,在打 ...
- 19、SOAP安装,运用与比对结果解释
转载:http://www.dengfeilong.com/post/Soap2.html https://blog.csdn.net/zhu_si_tao/article/details/71108 ...
- CF407B Long Path
好玩的题. 首先我们(看一下题解之后)发现当你第一次走到了一个点的时候,那么它之前的所有点一定都访问过了偶数次. 假设我们第一次走到了一个点$i$,那么$i - 1$一定访问了偶数次,那么第一次走$i ...
- MagicNotes:如何迈向工作的坦途
MagicNotes,思绪随风飞扬,不抓住写下来明天就会忘记了. 昨晚在知乎上偶尔看到 @雨农 的关于“为什么我那么努力,吃了那么多苦,也没见那么优秀?”的一个回复,心里有所触动. 本人专科毕业3-4 ...
- Win7怎么进入安全模式 三种轻松进入Win7安全模式方法
发布时间:2013-05-27 11:23 作者:电脑百事网原创 来源:www.pc841.com 13783次阅读 win7的安全模式和XP如出一辙,在安全模式里我们可以删除顽固文件.查杀病毒.解除 ...