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. ...
随机推荐
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 2_Linear regression with one variable 单变量线性回归
Lecture2 Linear regression with one variable 单变量线性回归 2.1 模型表示 Model Representation 2.1.1 线性回归 Li ...
- node.js开发指南读书笔记(1)
3.1 开始使用Node.js编程 3.1.1 Hello World 将以下源代码保存到helloworld.js文件中 console.log('Hello World!'); console.l ...
- java Web 过滤器Filter详解
简介 Filter也称之为过滤器,Web开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态图片文件或静态 html 文件等进行拦截,从而实现一些特殊 ...
- AJAX省市县三级联动的实现
省市县数据 本例子中省市县数据保存在MySQL数据库中,部分数据截图如下: 从数据库中读取数据 导入需要的jar包 连接池配置文件 <c3p0-config> <!-- 默认配置,如 ...
- 微信小程序怎么获取用户输入
能够获取用户输入的组件,需要使用组件的属性bindchange将用户的输入内容同步到 AppService. <input id="myInput" bindchange=& ...
- Win10 Tensorflow 配置Mask_RCNN
1.安装Anaconda3 下载地址 Anaconda 官网下载地址:https://www.continuum.io/downloads 下载以后,点击exe程序,开始安装,详细的安装过程(图片参 ...
- 766. Toeplitz Matrix斜对角矩阵
[抄题]: A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now ...
- 12-在eclipse上安装lxml
1.可用easy_install安装方式,也可以用pip的方式: pip install lxml 2.安装完毕:写代码导包时提示错误,这是需要配置一下eclipse,是因为它没有更新导入的包,所以需 ...
- Linux 与 BSD
1)Linux 与 BSD 有什么不同? http://linux.cn/article-3186-1.html 2)BSD(Unix)家族 http://blog.csdn.net/cradmin/ ...
- openpyxl模块处理excel文件
python模块之——openpyxl 处理xlsx/ xlsm文件 项目原因需要编辑excel文件,经过查询,最先尝试xlwt .wlrd这个两个模块,但是很快发现这两个模块只能编辑xls文件,然而 ...